how to choose 1 element from 2 different arrays in javascript code example

Example 1: 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 2: array in js

function Array() { return []; }

alert(Array(1, 2, 3)); // An empty alert box

Tags:

Java Example