Tell us what’s happening:
I have done everything correctly (it even shows correctly when I put my code into a different code editor) but on freecodecaamp it keeps returning that it’s not correct.
The test run results says :
You should use the && operator once (which I have)
You should have only one if statement (which I have)
all the console.logs when I run the test show the correct /expected values
I tried using <=50 && >= 25 as well as >=25 && <=50 (see below)
The task asked me to replace the two if statements with one statement, using the && operator, which will return "Yes"
if val
is less than or equal to 50
and greater than or equal to 25
. Otherwise, will return "No"
.
The original test page showed this:
function testLogicalAnd(val) {
// Only change code below this line
if (val) {
if (val) {
return "Yes";
}
}
// Only change code above this line
return "No";
}
testLogicalAnd(10);
Your code so far
function testLogicalAnd(val) {
// Only change code below this line
if (val <= 50 && val >= 25) {
return "Yes";
}
// Only change code above this line
return "No";
}
console.log(testLogicalAnd(10));//console shows No
console.log(testLogicalAnd(0));//console shows No
console.log(testLogicalAnd(24));//console shows No
console.log(testLogicalAnd(25));//Yes
console.log(testLogicalAnd(30));//Yes
console.log(testLogicalAnd(50));//Yes
console.log(testLogicalAnd(51));//No
console.log(testLogicalAnd(75));//No
console.log(testLogicalAnd(80));//No
```js
function testLogicalAnd(val) {
// Only change code below this line
if (val >= 25 && val <= 50) {
return "Yes";
}
// Only change code above this line
return "No";
}
console.log(testLogicalAnd(10));//console shows No
console.log(testLogicalAnd(0));//console shows No
console.log(testLogicalAnd(24));//No
console.log(testLogicalAnd(25));//Yes
console.log(testLogicalAnd(30));//Yes
console.log(testLogicalAnd(50));//Yes
console.log(testLogicalAnd(51));//No
console.log(testLogicalAnd(75));//No
console.log(testLogicalAnd(80));//No