Plese help me with this javascript code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0
28th Jul 2020, 7:14 AM
Abhishek Kumar
Abhishek  Kumar - avatar
2 Answers
+ 5
The problem is that, the 'name' is a reserved word in JavaScript and that's the reason it is showing error. However, if you still want to use 'name' as your function name, you can try changing the first word into capital, i.e. 'Name' it would definitely work. i.e., HTML <button onclick = "Name()">Click me</button> JavaScript Function Name(){ document.write("namaste"); }
28th Jul 2020, 7:25 AM
Adebayo Inioluwa Marvellous
Adebayo Inioluwa Marvellous - avatar
+ 2
Thanks Krishna for the help.
28th Jul 2020, 7:20 AM
Abhishek Kumar
Abhishek  Kumar - avatar