Advertisement
vvsvvs

Untitled

Sep 30th, 2022
972
0
122 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2.     let action = listProcesor();
  3.  
  4.     for (const task of input){
  5.         let [func, arg] = task.split(" ");
  6.        
  7.  
  8.         action[func](arg);    
  9.     }
  10.  
  11.     function listProcesor(arg){
  12.         let data = [];
  13.  
  14.         let result = {
  15.             add: (arg) => {
  16.                 data.push(arg);
  17.             },
  18.  
  19.             remove: (arg) => {
  20.                 data = data.filter(el => el != arg);
  21.             },
  22.  
  23.             print: () => {
  24.                 console.log(data.join(","));
  25.             }
  26.         }
  27.         return result;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement