diff --git a/commands.js b/commands.js old mode 100644 new mode 100755 index 4c5bff5..38da644 --- a/commands.js +++ b/commands.js @@ -14,11 +14,15 @@ function evaluateCmd(userInput) { case 'echo': commandLibrary.echo(roy.red(userInputArray.slice(1).join(' '))); break; - case 'cat': + case 'cat': commandLibrary.cat(userInputArray.slice(1)); break; case 'royecho': commandLibrary.roy(userInputArray.slice(1)) + case 'babyblue': + commandLibrary.babyblue(userInputArray.slice(1)) + // case 'heybaby': + // commandLibrary.baby(userInputArray.slice(1)) } } @@ -38,8 +42,12 @@ const commandLibrary = { }, roy: function(userInput) { done(roy.rainbowMe(userInput.join(' '))); + }, + babyblue: function(userInput) { + done(roy.babyBlue(userInput)); } + }; exports.commandLibrary = commandLibrary; -exports.evaluateCmd = evaluateCmd; \ No newline at end of file +exports.evaluateCmd = evaluateCmd; diff --git a/roygbiv.js b/roygbiv.js old mode 100644 new mode 100755 index 5b971d1..487009c --- a/roygbiv.js +++ b/roygbiv.js @@ -16,11 +16,11 @@ const LIGHT_CYAN = '\033[1;36m'; const WHITE = '\033[1;37m'; const NO_COLOR = '\033[0m'; const RAINBOW = [ - 'red', - 'orange', - 'yellow', - 'green', - 'blue', + 'red', + 'orange', + 'yellow', + 'green', + 'blue', 'purple' ] @@ -101,9 +101,16 @@ exports.noColor = (str) => { return addColor(NO_COLOR, str); } +// map() creates a new array by calling the provided function on every element of the calling userInputArray +// Carrie is probably splitting the string and rejoining it because she wants to use different colors for each of the characters; need to look at the RAINBOW definition to understand + exports.rainbowMe = (str) => { return str.split('').map((x, i) => { var color = RAINBOW[i % RAINBOW.length]; return x === ' ' ? x : exports[color](x); }).join(''); -} \ No newline at end of file +} + +exports.babyBlue = (str) => { + return addColor(LIGHT_BLUE,str); +}