varoables in js code example

Example 1: varoables in js

var oneVariable = 22;
var twoVariable = 24;

if (oneVariable != twoVariable){
	var same = 2;
  	if (oneVariable + same){
    	cosnole.log("oneVariable it's same than twoVariable")
    }
} else {
	var help = 1;
  	(oneVariable + help) {
    	console.log("oneVarible is more big than twoVarible")
    }
    
}

Example 2: javascript declare a variable

//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 reassigned

Example 3: js variables

// let & var are both editable variables:
var cow = 'moo';
let pig = 'oink';
cow = 10;
pig = 10;
// const is a permanent variable; you cannot change it.
const uncuttableGrass = '\/\/';
uncuttableGrass = '___';
// above throws an error

Tags:

Misc Example