Assessment wanted for Functions 3 skill test

Im stuck with an error: output is not defined
Trying to split the code from Functions 1 skill test so, that the randomIndex is calculated in separate function.

Here’s my code:

let names = ['Chris', 'Li Kang', 'Anne', 'Francesca', 'Mustafa', 'Tina', 'Bert', 'Jada']
let para = document.createElement('p');

// Add your code here
function chooseName(names) {
    let randomIndex = random(names.lengt); 
    para.textContent = names[randomIndex];

function random(randomIndex) {
    randomIndex = Math.floor(Math.random() * randomIndex);
    return randomIndex;


// Don't edit the code below here!
section.innerHTML = ' ';

Hi @T_H! I think your code looks pretty good. When I try it, it works OK after I fix the typo :wink:

(it’s in line 6)

You can also check out the marking guide to see how we did it: