Freecodecamp: Modify instruction in Challenge Comparison with the Greater Than Or Equal To Operator

Created on 15 Nov 2016  路  7Comments  路  Source: freeCodeCamp/freeCodeCamp

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 (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 testGreaterOrEqual(val) {
  if (val >= '20') {  // Change this line
    return "20 or Over";
  }

  if (val >= 10) {  // Change this line
    return "10 or Over";
  }

  return "9 or Under";
}

// Change this value to test
testGreaterOrEqual(9.999999999999999);

image

ISSUE:
the above code returns "9 or under" string as the result which is misleading or does not sound right when we use testGreaterOrEqual(9.999999999999999); as the input.

first timers only help wanted

All 7 comments

Returned text should be "Less than 10"

Using "Less than 10" _may_ confuse some people to think it includes 10. Another (arguably simpler) workaround is to mention that the function assumes the input to be integers. That way you only have to add text rather than change two test texts and the seed code. Either way, works for me.

@erictleung how about adding these type of documentation?

/**
 * @param {number} val Integer number
 */
function testGreaterOrEqual(val) {

@abhisekp I like it but I don't think this would be the place to introduce that. We'd have to introduce them way earlier and change all of the challenges. So I don't think there would be too much to gain from adding them. But I'm up for discussion on it.

Maybe for the intermediate and advanced algorithms that would be a clean and nice way to specify the parameters.

Considering the challenge https://www.freecodecamp.com/challenges/comparison-with-the-less-than-or-equal-to-operator with issue https://github.com/FreeCodeCamp/FreeCodeCamp/issues/11663 and the current issue, I think it is better to just modify the challenge seed.

i.e. the challenge seed should read "Less than 10".

I'd like to take a crack at this, i've never contributed before.

I don't want to steal anyone's thunder, but its been a few days since @billywaite said he was gonna attempt it. I'm going to throw my hat into the ring as well and attempt it.

Was this page helpful?
0 / 5 - 0 ratings