Assessment, function 1

I am learning functions and doing the exercise ‘Test your skills: functions’. Can anyone help me check my answer below if it is correct ?

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

// Add your code here

function chooseName() {
para.innerHTML = names[Math.floor(Math.Random() * names.length)];
}

// Don’t edit the code below here!

section.innerHTML = ’ ';

section.appendChild(para);

1 Like

Hi @JabriJuhinin93 and welcome to the community :wave:

Congratulations! Your code is correct.

If you plan on doing more tasks it would be helpful if you could share your code in an online editor like https://codepen.io/, https://glitch.com or https://jsfiddle.net/. It’s much easier when we can look at running code. Thank you :blush:

Have a nice day,
Michael

1 Like