1//variables are a way to easily store data in javascript
2//variables are declared by the var keyword, example...
3var x = 10;
4//or
5var dog_name = "daisy";
6//which can also be written as
7var dog_name = 'daisy';
8//same thing with single quotes and double quotes
1//How to make a variable equal a specific element in javascript.
2
3/*====DESCRIPTION STARTS HERE=======
4Assuming you've already created an array and a variable, you simply set the
5variable equal to the array, specifying the specific location of the value
6it holds. Note though that when specifying the location, subtract one
7number from the actual number we percieve. The reason for this is that computers
8begin counting at 0.
9 =====DESCRIPTION ENDS HERE========*/
10
11//=====EXAMPLE=========
12var listOfFirstNames = ["Will", "Kotori", "Grace", "James"]
13var FirstName = listOfFirstNames[2] /*firstName now has the value of "Grace"
14 since grace is the 2nd (or 3rd) element
15 of the array*/
16
1// data from json: resp = {"home": 1, "landmark": 2}
2// Method 1:
3// use ` for add variable
4url = `workspace/detail/${resp.home}`;
5console.log(url) -> // workspace/detail/1
6
7// Method 2:
8// use ' and + for concentrace variable
9url = 'workspace/detail/' + resp.home;
10console.log(url) -> // workspace/detail/1
11