JS Challenge:1

·

1 min read

We use let and const keywords to create variables in modern JavaScript. const is the short form of Constant, hence never use it if the variable gets reassigned.

Note: Use const wherever possible and use let only when you know that the variable will be reassigned later.

Example:

const Name = "Arun"
let wishes = "Good morning"
wishes= "Good evening"

Note that the variable wishes gets reassigned from "good morning" to "Good evening", in such cases let is the right choice. And also see that Name variable never gets reassigned in the code hence const is the first choice though let also will work fine. Using const improves code readability.

Challenge:

  1. Create a variable with name 'score' and reassign its value.
  2. Create a constant with name 'Pi' and value '3.14'