I'm working on an exercise but I'm not able to understand why my prompt is not being stored as a string and therefore can't be compared to my switch case
Any input returns false:
function getColor(selection) {
switch (selection) {
case 'red':
return true;
case 'green':
return true;
case 'blue':
return true;
default:
return false; //returns false because the user picked an unavailable color
}
}
var colorname = prompt('What color do you want?');
var isAvailable = getColor(colorname);
if (getColor === true) {
console.log('Good news! That color is available');
} else {
console.log('We are sorry, that color is not available');
}
I noticed the input is not being stored as a String as I tried to .toUpperCase the "colorname" var and it won't change to Upper Case.