hasBeenGood: false
},
{
name: "Astrid",
hasBeenGood: true
}
]
// Task:
// - Write the JavaScript to sort the people in sorteesArr into the naughty and nice lists,
according to whether they have been good or not. Then display the names in the relevant place in
the DOM.
const createListItem = (sortee) => {
return `<li>${sortee.name}</li>`
}
btn.addEventListener('click', () => {
sorteesArr.forEach(sortee => {
sortee.hasBeenGood ? niceList.innerHTML += createListItem(sortee) : naughtyList.innerHTML
+= createListItem(sortee)
})
})
// Stretch goals:
// - Add the option to add new names to the sorteesArr.
// - Make it possible to switch people to the other list.
const niceList = document.getElementById("nice-list")
const naughtyList = document.getElementById("naughty-list")
const btn = document.getElementById("btn")
// btn.addEventListener("click", sort)
const sorteesArr = [
{
name: "David",
hasBeenGood: false
},
{
name: "Del",
hasBeenGood: true
},
{
name: "Valerie",