I know this is a beginner's question, but I don't understand why the following syntax error occurs:
...
else if (artist1.toLowerCase() == "anister huls" && title1.toLowerCase() == "i remember yesterday") || (artist1.toLowerCase() == "belle" && title1.toLowerCase() == "rock the boat") {
var cover = "http://my_url/img/tag/same_image.jpg";
}
...
Result:
Uncaught SyntaxError: Unexpected token '||'
Error occurs only with ||
operator.
This syntax would be correct in JavaScript, why doesn't it work in jQuery?
You are missing some parenthesis. An If
statement condition requires parenthesis around the entire condition check.
Change
else if (artist1.toLowerCase() == "anister huls" && title1.toLowerCase() == "i remember yesterday") || (artist1.toLowerCase() == "belle" && title1.toLowerCase() == "rock the boat") {
to
else if ((artist1.toLowerCase() == "anister huls" && title1.toLowerCase() == "i remember yesterday") || (artist1.toLowerCase() == "belle" && title1.toLowerCase() == "rock the boat")) {