A JavaScript program is a sequence of statements, each performing a task:
Semicolons are used to separate statements, though JavaScript can often infer them. Best practice is to always use semicolons:
let name = "Alice";
console.log(name);JavaScript is case-sensitive. The following two variables are different:
Be consistent with your naming conventions.
Use comments to document your code:
// This is a single-line comment
/*
This is a
multi-line comment
*/Whitespace is ignored, but use indentation for clarity:
function greet() {
let name = "John";
console.log("Hello, " + name);
}Curly braces {} define blocks of code, especially in functions, loops, and conditionals:
if (x > 0) {
console.log("Positive");
}Ask the AI if you need help understanding or want to dive deeper in any topic