OneBite.Dev - Coding blog in a bite size

declare an integer in Javascript

Code snippet on how to declare an integer in Javascript

let number = 5;

This code uses the keyword ‘let’ to declare a new integer variable named ‘number’ and assign it the value of ‘5’. The keyword ‘let’ is used to assign values to a variable and must be used every time a new variable is declared. The ’=’ sign is the assignment operator and is used to assign values to variables. In this case, it assigns the value of ‘5’ to the new variable ‘number’. As the value is an integer, the number can only be an integer. It must also not contain any quotes or special characters. If the value were a string, for example, then the value would need to be surrounded by quotes.

javascript