JavaScript

Variables

let

Use let to declare most of variables.

const

Use const to declare variable that is a constant. That is not going to change.

var

var is an old way to declare variables. Avoid using it. Use let instead.


Prompt and alert

let varName = prompt ("Value:", "");
alert ("Message");
let userName = prompt ("User name:", "");
alert (`Greetings, ${userName}!`);

// prompt: User name: ___ 
// (Kitten entered)
// alert: Greetings, Kitten!