In this exercise, you’ll refactor some ES5 code into ES2015.
var PI = 3.14;
PI = 42; // stop me from doing this!
/* Write an ES2015 Version */
const PI = 3.14;
PI = 42; //error
Quiz
- What is the difference between var and let?
- var allows mutability and reassignment, while let only allows mutability.
- What is the difference between var and const?
- var allows mutability and reassignment, while const allows neither.
- What is the difference between let and const?
- let allows mutability, while const does not. neither allow reassignment
- What is hoisting?
- when variables can be used before they are declared
Solution
See Our solution.