How do I run code I have written in JavaScript?

  1. open an editor. Simplest one is notepad
  2. Write basic HTML there like below<html> <head> </head> <body> Hello World! </body> </html>
  3. Add a script tag and write your js inside it like below<html> <head> <script> alert("hello"); </script> </head> <body> Hello World! </body> </html>
  4. or you can write your js code in a file and save as .js file and link that in the above code<html> <head> <script src="myScript.js"></script> </head> <body> Hello World! </body> </html>
  5. Save this as yourfile.HTML and open in any browser

Leave a Comment