0

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.

5

1 Answer 1

2

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);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.