0
28th Jul 2020, 7:14 AM
Abhishek Kumar
Abhishek  Kumar - avatar
3 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
Coolbuoy
Coolbuoy - avatar
+ 2
Thanks Krishna for the help.
28th Jul 2020, 7:20 AM
Abhishek Kumar
Abhishek  Kumar - avatar