Answers for "how to add a variable in js"

3

how to write a variable in js

//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
Posted by: Guest on June-03-2020
1

add variables in javascript

var a = 5;
var b = 2;
var c = a + b;
Posted by: Guest on March-24-2021
0

how to add a variable in js

var x = 5;         // assign the value 5 to x
Posted by: Guest on November-26-2020
0

how to add a variable in js

var x = 5;         // assign the value 5 to x
Posted by: Guest on November-26-2020
0

how to assign variables in javascript

// data from json: resp = {"home": 1, "landmark": 2}
// Method 1: 
// use ` for add variable
url = `workspace/detail/${resp.home}`;
console.log(url) -> // workspace/detail/1
  
// Method 2: 
// use ' and + for concentrace variable
url = 'workspace/detail/' + resp.home;
console.log(url) -> // workspace/detail/1
Posted by: Guest on March-25-2021

Code answers related to "how to add a variable in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language