0

code image

When I call the function, it must display A random person's name.

1

2 Answers 2

1

You should correct names.length to listof names.length for example enter image description here

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

Comments

0
// You only add a paramter when you provide an argument when calling the function, for example if the listOfNames array was outside the function
function whosPaying() {
    let listOfNames = ["Mohamed", "Ahmed", "Farah", "Yusuf", "Dahir"];
    let numberOfPeople = Math.floor(Math.random() * listOfNames.length);

    let randomPerson = listOfNames[numberOfPeople];
    return randomPerson + " is going to buy lunch today!";
}
console.log(whosPaying());

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.