I get the error message of you should have only one if statement, but when I remove one I get an error message on all of the tests, when I only had 2 with 2 if statements can I please get help here.
Your code so far
function testLogicalAnd(val) {
// Only change code below this line
if (val) {
if (val<= 50 && val >= 2) {
return "Yes";
}
}
// Only change code above this line
return "No";
}
testLogicalAnd(10);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Challenge Information:
Basic JavaScript - Comparisons with the Logical And Operator
The instructions is asking: Replace the two if statements with one statement, using the && operator, which will return the string Yes if val is less than or equal to 50 and greater than or equal to 25. Otherwise, will return the string No.
Replace the two if statements with one statement, using the && operator, which will return the string Yes if val is less than or equal to 50 and greater than or equal to 25 . Otherwise, will return the string No .
You should have only one if statement.
Also, check that both conditions are met.