I want to initiate a code if the user has entered a specific symbol or string. In this task I need to check if the user has entered any of the following : "a","b","c","d". However it seems to just ignore the if statements.
Here is the whole problem: Write a program that determines the color of a chessboard square based on its Label and Rank. Input: On the first line, you will receive L - the label On the second line, you will receive R - the rank
let L = prompt();
let R = Number(prompt());
if (L == ("a", "c", "e", "g")) {
if (R % 2 == 0) {
/*if we are on a/c/e/g lines and the number is even the
square is white*/
console.log("light");
} else {
console.log("dark");
} //else it is going to be odd therefore dark
} else if (L == ("b", "d", "f", "h")) { //opposite logic:
if (R % 2 == 0) {
console.log("dark");
} else {
console.log("light");
}
}
The problem is I don't know how to compare the two strings. I tried with some of the string methods but I guess I am just making a sintax error