Hi there ,
Is my solution correct ?
const names = ['Chris', 'Li Kang', 'Anne', 'Francesca', 'Mustafa', 'Tina', 'Bert', 'Jada']
const para = document.createElement('p');
// Add your code here
function random(num) {
return Math.floor(Math.random() * num);
}
function chooseName(arr) {
return arr[random(arr.length)]
}
para.textContent = chooseName(names)
// Don't edit the code below here!
section.innerHTML = ' ';
section.appendChild(para);
Can i improve that ?, because I’m not sure
“making it more flexible” means I can passed the argument with const anotherArray = ['a', 'b', 'c']
when invoke chooseName(anotherArray)
and respective with the length. Is like that?