OneBite.Dev - Coding blog in a bite size

declare a local variable in Javascript

Code snippet on how to declare a local variable in Javascript

  let myVariable = 'example';

This code declares a new local variable called “myVariable” and assigns it a string value of “example”. The “let” keyword tells the Javascript interpreter to create a local variable, which means it is only available in the current scope. The assignment operator ”=” assigns the value “example” to the variable. Strings in Javascript are denoted with single or double quotes. In this case, single quotes are used. Finally, a semicolon is added to denote the end of the statement.

javascript