Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let list = [];
- for (let line of input) {
- let tokens = line.split(' ');
- let name = tokens[0];
- if (tokens.length===3) {
- let isIncluded = list.includes(name);
- if (isIncluded) {
- console.log(`${name} is already in the list!`);
- } else {
- list.push(name);
- }
- } else {
- let indexOfPerson = list.indexOf(name);
- if(indexOfPerson===-1){
- console.log(`${name} is not in the list!`);
- } else {
- list.splice(indexOfPerson, 1);
- }
- }
- }
- console.log(list.join('\n'));
- }
- //Write a function that keeps track of guests that are going to a house party.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement