Skip to content

Instantly share code, notes, and snippets.

@willshepp28
Created December 10, 2020 18:09
Show Gist options
  • Save willshepp28/d1c185655c5a51ed8af392b6920d344f to your computer and use it in GitHub Desktop.
Save willshepp28/d1c185655c5a51ed8af392b6920d344f to your computer and use it in GitHub Desktop.
/**
* @param {string} command
* @return {string}
*/
var interpret = function(command) {
let output = '';
for(let i = 0; i < command.length; i++) {
if(command[i] === "G") {
output += "G"
} else if (command[i] === "(") {
if(command[i+1] === ")") {
output += "o"
} else if(command[i+1] === "a" && command[i+2] === "l" && command[i+3] === ")") {
output += "al"
}
}
}
return output;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment