Reputation: 59
I have created an array
var array1 = new Array("jack", "kaziu", "wladek");
var display = Math.floor((Math.random() * array1.length));
console.log(display)
I cannot figure out how to display characters instead of numbers (array1's length). Appreciate for help.
Upvotes: 0
Views: 51
Reputation: 13964
Index the array with your calculated index:
const array1 = new Array("jack", "kaziu", "wladek");
const display = array1[Math.floor(Math.random() * array1.length)];
console.log(display);
Upvotes: 2