Member-only story

Learn to write your first JavaScript Code!

Ankit Maheshwari
2 min readSep 7, 2024

--

[3] JavaScript Basics to Advanced Series: In this article we will to write JavaScript code inline and in external JS file.

My articles are open for everyone; non-member readers can read the article by clicking this link.

In order to write JavaScript code we need a script element.

  • The <script> element can be added in <head> section or in the <body> section of HTML page.
  • But the best practice is to put the <script> element at the end of the <body> section. Because browser parse the code from top-to-bottom and other HTML element need to be executed before the execution of JavaScript code.
  • Type script and press tab - this will add <script> element. (Check video below↓)
  • Add console.log("Hello World!"); and save.
  • Open up chrome — right click — click inspect — open console tab — see the log “Hello World!”
  • console.log("Hello World!");
  • Here "Hello World!" is a string in…

--

--

Ankit Maheshwari
Ankit Maheshwari

No responses yet