Challenge Waypoint: Logical Order in If Else Statements has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
.
My code:
function myTest(val) {
if(val < 5) {
return "Less than 5";
} else if(val < 10) {
return "Less than 10";
} else {
return "Greater than or equal to 10";
}
}
// Change this value to test
myTest(7);
It is only a minor mistake but the first Test being done to check the code says >myTest(5) should return "Less than 5"
- Im pretty sure it should say >myTest(4) should return "Less than 5"
tho since 5 isnt less than 5. This seems to be only a mistake in this Text and not in the test itself since the correct code is accepted.
I thoroughly agree with you, amenshamen. The logic here isn't right. It should be a number smaller than 5 in the test case in order for the logic to make sense because 5 is not less than 5.
Agreed.
Agreed.
Was about to make and issue too. Agreed +1
I have the same code that you have and it's not working. Something is amiss!
Agreed. Was about to report the bug.
agree
SOLUTION :
removed solution by mod
SOLUTION :
removed solution by mod
THERE SHOULD BE SOME CORRECTION.... IN FIRST IF STATEMENT IF WE PUT VAL >=5....IT WILL BE MORE LOGICAL BECAUSE IF WE DONT PUT >= INSTEAD PUT ONLY > ...THEN WHILE INVOKING THE FUNCTION...IF WE GIVE ARGUMENT AS 5 THEN IT WILL RETURN GREATER THAN OR EQUAL TO 10....
JUST A THOUGHT.....WHAT YOU SAY
why in the free code camp this code is not work ning
function myTest(val) {
if(val < 5) {
return "Less than 5";
} else if(val < 10) {
return "Less than 10";
} else {
return "Greater than or equal to 10";
}
}
// Change this value to test
myTest(4);
i teste in the console and is working , admin can you fix please
thanks @misterds for helping me solve the problem.
Answer
function orderMyLogic(val) {
if (val < 5) {
return "Less than 5";
} else if (val < 10) {
return "Less than 10";
} else {
return "Greater than or equal to 10";
}
}
orderMyLogic(7); // Less than 10
Mr. @misterds
Try this code
function orderMyLogic(val) {
if (val < 5) {
return "Less than 5";
} else if (val < 10) {
return "Less than 10";
} else {
return "Greater than or equal to 10";
}
}
orderMyLogic(7); // Less than 10
Most helpful comment
SOLUTION :
removed solution by mod