Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions commands.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand All @@ -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;
exports.evaluateCmd = evaluateCmd;
19 changes: 13 additions & 6 deletions roygbiv.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]

Expand Down Expand Up @@ -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('');
}
}

exports.babyBlue = (str) => {
return addColor(LIGHT_BLUE,str);
}