let keyword, followed by its name and the data it should hold.
In this example, we've created a variable called
favoriteColor and stored the string "blue" inside it. You can change the value of a variable at any time.
favoriteColor holds the string "green".
const keyword to create a constant variable.
Here, we've created a constant called
daysInWeek and assigned it the value 7. Once defined, constants cannot be changed.
function keyword, followed by its name, a pair of parentheses, and a code block enclosed in curly braces.
In this example, we've created a function called
greet which logs "Hello, world!" to the console. To invoke this function, simply call it by its name followed by parentheses.
else if, and
else statements, you can create code branches that execute only when specific conditions are met.
age variable is greater than or equal to 18. If it is, it logs "You can vote!" to the console. If not, it logs "You are too young to vote."
while loops to cycle through code blocks until a condition is no longer met.
for loop runs five times, logging "Loop iteration: 0" through "Loop iteration: 4" to the console.