javascript array values code example

Example 1: MDN array length

const clothing = ['shoes', 'shirts', 'socks', 'sweaters'];

console.log(clothing.length);
// expected output: 4

Example 2: how to get array values in javascript

var valueAtIndex1 = myValues[1];

Example 3: js array

var colors = [ "red", "orange", "yellow", "green", "blue" ]; //Array

console.log(colors); //Should give the whole array
console.log(colors[0]); //should say "red"
console.log(colors[1]); //should say "orange"
console.log(colors[4]); //should say "blue"

colors[4] = "dark blue" //changes "blue" value to "dark blue"
console.log(colors[4]); //should say "dark blue"
//I hope this helped :)

Example 4: javascript get array value

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
}