Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Last active May 28, 2021 18:41
Show Gist options
  • Save jamiejohnsonkc/30e3cf8c274a6c9f34b4da088193c25e to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/30e3cf8c274a6c9f34b4da088193c25e to your computer and use it in GitHub Desktop.
guest list
const people = ['Chris', 'Anne', 'Colin', 'Terri', 'Phil', 'Lola', 'Sam', 'Kay', 'Bruce'];
const admitted = document.querySelector('.admitted');
const refused = document.querySelector('.refused');
admitted.textContent = 'Admit: ';
refused.textContent = 'Refuse: '
for (let i = 0; i < people.length; i++) {
if (people[i] === 'Phil' || people[i] === 'Lola') {
refused.textContent += `${people[i]}, `;
}
else {
admitted.textContent += `${people[i]}, `;
}
}
refused.textContent = refused.textContent.slice(0,refused.textContent.length-2) + '.'
admitted.textContent = admitted.textContent.slice(0,admitted.textContent.length-2) + '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment