Advertisement
Guest User

Untitled

a guest
May 4th, 2020
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input = []) {
  2.     let splitting = input.shift().split(`!`);
  3.     let commands = input.shift();
  4.  
  5.     while (commands !== 'Go Shopping!') {
  6.         let tokens = commands.split(' ');
  7.         let command = tokens[0];
  8.         let item = tokens[1];
  9.  
  10.         if (command === 'Urgent') {
  11.             if (item === splitting[0]) {
  12.                 break;
  13.             }
  14.  
  15.             else {
  16.                 splitting.unshift(item);
  17.             }
  18.         }
  19.     }
  20.     console.log(splitting);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement