zixuan
0
Q:

javascript get array value

// Javasscripts Arrays are not fixed length
var person = [];
person[0] = "John";
person[1] = "Doe";
person[2] = 46;

var x = person.length;     // person.length will return 3
var y = person[0];         // person[0] will return "John"
3
var array = []
array[0] = "hi"
array[1] = "dude"
var done = false
while (done == false){
var valueToFind = "hi";
  var rounds = array.length;
  if (rounds < 0){
  return false
  }
  if (array[rounds] == valueToFind){
  done = true
    return rounds
  }
  rounds = rounds - 1
}
1
var valueAtIndex1 = myValues[1];
3
let names = ['Michael', 'Adam', 'NetNinja'];
//now you are free to use the array
conosle.log(names[0]);
-2

New to Communities?

Join the community