Skip to content

Instantly share code, notes, and snippets.

@Blazing-Mike
Created March 1, 2022 00:46
Show Gist options
  • Save Blazing-Mike/e0676e9929ff20303abed27255a9ca2d to your computer and use it in GitHub Desktop.
Save Blazing-Mike/e0676e9929ff20303abed27255a9ca2d to your computer and use it in GitHub Desktop.
/* For the first task, you have to create a simple function — chooseName() — that prints
a random name from the provided array (names) to the provided paragraph (para), and then run it once. */
const names = ['Chris', 'Li Kang', 'Anne', 'Francesca', 'Mustafa', 'Tina', 'Bert', 'Jada']
const para = document.createElement('p');
function chooseName(){
let eachName = names[Math.floor(Math.random() * names.length)];
para.textContent = eachName;
}
chooseName();
// Don't edit the code below here!
section.innerHTML = ' ';
section.appendChild(para);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment