Here is the task:
In English, the colors of the rainbow are often listed as:
red orange yellow green blue indigo violet
Declare a function called
isRainbowColor. Use case-insensitive checking, i.e."red","Red","RED","ReD", and"rEd"are all valid rainbow colors./** @param {string} ??? - the color to check @returns {boolean} whether or not the given color is a rainbow color */
Here is what I have so far (I know this is not enough!):
function isRainbowColor(string){
let rainbowColor = [];
for (const string of rainbowColor){
if (string != rainbowColor){
return true;
}else{
return false;
}
}
}
Here is the error message that I get:
Here is the test that I could not pass with my code above:
actual = isRainbowColor("red");
expected = true;
if (actual === expected) {
console.log("Test PASSED!");
} else {
console.error("Test FAILED. Keep trying!");
console.group("Result:");
console.log(" actual:", actual);
console.log("expected:", expected);
console.groupEnd();
}
actual = isRainbowColor("rEd");
expected = true;
if (actual === expected) {
console.log("Test PASSED!");
} else {
console.error("Test FAILED. Keep trying!");
console.group("Result:");
console.log(" actual:", actual);
console.log("expected:", expected);
console.groupEnd();
}
actual = isRainbowColor("Brown");
expected = false;
if (actual === expected) {
console.log("Test PASSED!");
} else {
console.error("Test FAILED. Keep trying!");
console.group("Result:");
console.log(" actual:", actual);
console.log("expected:", expected);
console.groupEnd();
}
