question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modify instruction of challenge Comparison with the Less Than Or Equal To Operator

See original GitHub issue

Challenge 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);


image

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:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
robbawebbacommented, Nov 17, 2016

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.

1reaction
Adubiarocommented, Jan 12, 2017

this can be so confusing

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found