Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input = []) {
- let splitting = input.shift().split(`!`);
- let commands = input.shift();
- while (commands !== 'Go Shopping!') {
- let tokens = commands.split(' ');
- let command = tokens[0];
- let item = tokens[1];
- if (command === 'Urgent') {
- if (item === splitting[0]) {
- break;
- }
- else {
- splitting.unshift(item);
- }
- }
- }
- console.log(splitting);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement