Created
December 10, 2020 18:09
-
-
Save willshepp28/d1c185655c5a51ed8af392b6920d344f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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