Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr){
- let list = [];
- for (let i = 0; i < arr.length; i++) {
- let command = arr[i].split(' ');
- if (command.length == 3){
- let name = command[0];
- if (list.includes(name)){
- console.log(`${name} is already in the list!`);
- }
- else{
- list.push(name);
- }
- } else {
- let name = command[0];
- if (list.includes(name)){
- let index = list.indexOf(name);
- list.splice(index, 1);
- }
- else{
- console.log(`${name} is not in the list!`)
- }
- }
- }
- for (const el of list) {
- console.log(el);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement