how to define variable in javascript

JavaScript
var <variable-name>;

var <variable-name> = <value>;
	//variables can include any letter, any number, or the underscore
	//NO SPACES!!! USE UNDERSCORES!!!
	//variable names are case sensitive (i.e. this_variable is different from ThiS_VarIaBle)
	//example:
var change_this = 'whatever you want here'
	//change_this is a variable (change it to your variable name)
	//'whatever you want here' is an assignment to the variable change_this.//choose the best for your solution
var myVariable = 22; //this can be a string or number. var is globally defined

let myVariable = 22; //this can be a string or number. let is block scoped

const myVariable = 22; //this can be a string or number. const is block scoped anda variable is a something that holds a value.. ex: var age = 22; //the age is the variable that holds the value of two. We tell JS that it's a variable by using either var, let, or const
Source

Also in JavaScript: