Modify instruction of challenge Comparison with the Less Than Or Equal To Operator
See original GitHub issueChallenge Comparison with the Less Than Or Equal To Operator has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function testLessOrEqual(val) {
if (val <= 12) { // Change this line
return "Smaller Than or Equal to 12";
}
if (val <= 24) { // Change this line
return "Smaller Than or Equal to 24";
}
return "25 or More";
}
// Change this value to test
testLessOrEqual(24.99);
Issue: when I input testLessOrEqual(24.99); the answer or the code returns "25 or more " as the outcome which is not correct - this code might need some improvement
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Modify instruction in Challenge Comparison with the Greater ...
Challenge Comparison with the Greater Than Or Equal To Operator has an issue. User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 ...
Read more >Comparison and Logical Operators - Codecademy
Comparison operators allow us to assert the equality of a statement with JavaScript. For example, we can assert whether two values or expressions...
Read more >Review: Logic and if Statements (article) | Khan Academy
An if statement tells the program to execute a block of code, if a condition is true. In the code below, we output...
Read more >Chapter 3 | Python For Everyone | Trinket
Finally, the not operator negates a boolean expression, so not (x > y) is true if x > y is false; that is,...
Read more >Conditionals and Loops - Introduction to Programming in Java
java that takes an integer command-line argument n and prints all integers less than or equal to n that can be expressed as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe “More Than 24” is a more accurate return value because the values that make it to that else statement can be as close as possible to 24 without equaling 24 when approaching from the positive side. If I were to change the return value to “24.1 or more” and I passed the function a value of 24.05, 24.01, 24.001, the function would return the statement saying that the number is larger than 24.1, which is false.
this can be so confusing