Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Letter Queue by Sim0000
"use strict";
function letterQueue(commands){
let q = '';
for(let cmd of commands){
q = (cmd == 'POP') ? q.slice(1) : q + cmd.slice(-1);
}
return q;
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(letterQueue(["PUSH A", "POP", "POP", "PUSH Z", "PUSH D", "PUSH O", "POP", "PUSH T"]), "DOT", "dot example");
assert.equal(letterQueue(["POP", "POP"]), "", "Pop, Pop, empty");
assert.equal(letterQueue(["PUSH H", "PUSH I"]), "HI", "Hi!");
assert.equal(letterQueue([]), "", "Nothing");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
May 15, 2017
Comments: