first time posting!
I did some digging around and couldn’t find information on what I’m trying to achieve (sorry not the most advance javascript guy).
use case: prompt user a question, accept answer from user, weigh users’ answer to cases, return a result
problem: since javascript is case sensitive, im trying to learn how to accept both upper case and lower case in the prompt without using too many repetitive cases (ie. switch)
Below is a simple piece of code that I’m constructing to see if I can achieve the use case (obviously it’s not working though lol hence this question), thanks for the help in advance!
var jacketColor = function(x){
var x = prompt("color"?);
x===x.substring(0,1).toUpperCase||x===x.substring(0,1).toLowerCase)
};
}
var result;
switch (jacketColor) {
case "black":
result = "pay $300";
break;
case "brown":
result = "Pay $200";
break;
case "green":
result = "Pay $5";
break;
default:
result = "This color does not match my eyes!";
}
You code should look something like that: