4 ms·
What interests me here is that both your version and the else if version perpetuate the error in the original code which is the case where a is greater than b,
by drittich 4y ago
What interests me here is that both your version and the else if version perpetuate the error in the original code which is the case where a is greater than b, which is handled once by a "greater than" comparison, and then again by a "greater than or equal to" comparison, which is clearly redundant. Neither CoPilot, nor you, nor the article author I presume caught this error in the flow control. Catching errors like these adds more value then making it more readable, although making it more readable certainly did expose the error more clearly to me.
- Nullabillity 4y agoI did notice it but wanted to keep the AST identical. But yes, it would have been worth pointing out, heh.
- garaboncias2 4y agoActually it is not redundant as >= do numerical comparsion (so convert a and b to number) while == do not do that. So it has different result on objects.
- drittich 4y agoYou learn something new every day! I have written JavaScript off and on for years and did not encounter that.