const keyword is used to declare variables that have a constant value, meaning their value cannot be reassigned once it is set. This is particularly useful when you have a value that should remain constant throughout your code.
To declare a constant variable, it's similar to the
let syntax, just use the
const keyword followed by the variable name and the initial value assigned to it. Here's the syntax:
Declare a constant variable called
quantity and assign it the value 5.
Print the value of
quantity to the console.
Sign up to start coding
Already have an account?