Comparison with the Less Than Operation, please Help

Tell us what’s happening:
please where do i go wrong? ** testLessThan 24 is not activating, see my code below

Your code so far

function testLessThan(val) {
  if (val < 24) {  
    return "Under 25";
  if (val < 55) {  // Change this line
    return "Under 55";

  return "55 or Over";

// Change this value to test

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:

This checks if val is less than (under) 24.

Thanks, but isn’t allowing me to pass the challenge?

Here is the screenshot

Your latest screenshot shows the exact same code you originally posted. The answer that @BenGitter gave you is similar to what I will say.

Your first if statement is currently checking if val is less than 24. When the function is called with the number 24 as in the test case of testLessThan(24), that line is read as “Is 24 less than 24?” The answer is “No”, so “Under 25” is NOT returned. Then, the next if statement asks “Is 24 less than 55?” The answer is “Yes”, so “Under 55” is returned.

The bottom line here is you need to change your if statement condition to something that will cause “Under 25” to be returned if val is less than 25.

1 Like

thank you sir, it has been solved

A post was split to a new topic: Less Than Operation Help