Write a program that will fill the guest list. Put the guest to the admit if they are invited; if not, put it on refuse.
My code:
const admit = document.getElementById("admit");
const refuse = document.getElementById("refuse");
admit.textContent = "Admit: ";
refuse.textContent = "Refuse: ";
const people = [
"Chris",
"Anne",
"Colin",
"Terri",
"Phil",
"Lola",
"Sam",
"Kay",
"Bruce",
];
for (let i = 0; i < people.length; i++) {
if (people[i] === "Phil" || people[i] === "Lola") {
refuse.textContent += people[i] + ",";
} else {
admit.textContent += people[i] + ", ";
}
}
I got the program worked.
Admit: Chris, Anne, Collin,Terri,Sam,Kay,
Refuse: Phil,Lola,
But I'm trying to solve how to add and and replace the , with ..
Here is the output that I want:
Admit: Chris, Anne, Collin,Terri, Sam, Kay, and Bruce.
Refuse: Phil and Lola.