Your First JavaScript Program — JS Technical Interview Questions & Answers

Writing and running a simple script in the browser.

Your First JavaScript Program

  • Writing and running a simple script in the browser.
  • console.log('Hello JS'); in DevTools, or a .html file with a script tag. If nothing prints, the console is the wrong tab or the script path is wrong.
  • alert('Hi') also works but is annoying — use console in class.
  • Trap: script src file missing 404. Trap: running Node examples in the browser without thinking (require is not there).

Technical Interview Tip: console.log('Hello JS');

Code Examples for Your First JavaScript Program

Your First JavaScript Program — working example

// Single-line comment
/* Multi-line
   comment */
let score = 10; // statement ends with ;
const message = "Ready";
console.log(message, score + 5);

Your First JavaScript Program — statements, identifiers, and // or /* */ comments are the base of JS syntax.

How to Explain Your First JavaScript Program to an Interviewer

Where do you see console.log?

Browser DevTools console