Free JavaScript course. Sign Up for tracking progress →

JavaScript: Variable change

The word "variable" itself suggests that it can vary. Indeed, the value of a variable can change throughout your code.

let greeting = 'Father!';
console.log(greeting);
console.log(greeting);

greeting = 'Mother!';
console.log(greeting);
console.log(greeting);

The name remains unchanged, although it stores new data. Note the key difference between declaring a variable and changing it. The let keyword appears only when you create a variable, but when you modify it, you don't use a keyword.

Instructions

In the exercise, the variable comes with an initial string value. Override the variable and assign it the same string, but reversed, i.e., place the characters of the initial string in reverse order.

Definitions

  • Variable is a way to save data under a name for later use in code.