declare variable javascript

JavaScript
//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 and can't be reassignedvar variable = 10;

function start() {
  variable = 20;
}
console.log(variable + 20);

// Answer will be 40 since the variable was changed in the functionvar <variable-name>;

var <variable-name> = <value>;
// write what ever you want
// one way is
// this is to declare intigers
var a = 10;
//this is to declare strings aka words
var b = "hi";
// the key word var can be replaced by let
//like this
let a = 10;
let b = "hi";
// i recomend using let insted of varvar myVar;       //unitialized variable( can be intiallized later )
var number = 1; //number
var string = " hello world " ; //string
var boolean = true ;  //boolean
myVar = function(){  //variable can hold function
  
};
Source

Also in JavaScript: