OneBite.Dev - Coding blog in a bite size

create a variable in Javascript

Code snippet on how to create a variable in Javascript

  var myName = "John";

This code creates a variable called ‘myName’ and assigns it the value of “John”. Variables are like containers that store data which we can refer to later on in our code. In this example, we give our variable the name ‘myName’, and then assign it the string value “John”. This means that any time we use the variable ‘myName’ in our code, it will represent the value “John”. Variables can store many different types of values, including strings (like this example), numbers, Booleans, and more.

javascript