Index
let x = 5;
//reading 'x' value and assign to y
let y = x;
let myBox = [3.14, 9, 5, 40];
How to take a spice from spice box
- we need the box number
- the number starts from zero
index
let myBox = [3.14, 9, 5, 40]
console.log(myBox[0]) // 3.14
console.log(myBox[2]) // 5
index can be a variable
variable as index
let myBox = [3.14, 9, 5, 40];
let a = 2;
console.log(myBox[a])
answer
5