OneBite.Dev - Coding blog in a bite size

declare a float number in Javascript

Code snippet on how to declare a float number in Javascript

This code is declaring a float number in Javascript.

    let x = 24.5;

First, the keyword ‘let’ is used to create a variable called ‘x’. After that, an assignment operator ‘=’ is used to assign the number 24.5 to the variable. The number 24.5 is a float number because the decimal point denotes that the number has a fractional part. The semicolon (;) after the value of 24.5 is used to indicate the end of the statement. This terminates the float number declaration.

javascript