Logical Order in If Else Statements - additional explanation would be helpful #6483
@emilyanndavis I agree that the instructions should be reworded since "0 is less than 2" is no less correct than "0 is less than 1".
You're right that loop isn't the best word for this. I'd say it's incorrect to use loop in this context as nothing in the function suggests it is executed again automatically when a certain condition is true (which is what for
and while
loops do). The execution of the function is what's being exited/stopped when return
is called.
I agree that we could use more clarity here. The proposed text is probably too long. We need something to discuss expectations and precision. Overall, we try to keep the total length of the text to ~150-160 words, so keep that in mind.
Thanks, @alistermada. It's been over a decade since I last worked with loops, but I thought (hoped!) I was remembering correctly how they work. :)
And thanks, @SaintPeter. I suspected that text might be a little long, but I figured it was better to err on the side of too many words at first to be sure I was getting the point across. How about this instead:
Both statements are true, but "Less than one" is more precise. Due to the order of statements in function
bar(x)
,bar(0)
does not return the expected (i.e., more precise) result.
Then, in the Instructions, I would change "the correct statements" to "the most precise result."
Finally, I would also propose that the intro text:
be modified so that it reads either (1) "The function is executed..." or (2) "The statements are evaluated...". The rest of the sentence would remain the same; the key is that "loop" be changed to a more appropriate descriptor.
Yeah, these are not "loops". They are just if/else statements. That is definitely incorrect and should be fixed.
The key takeaway is that they are evaluated in order and that we're looking for a "more precise result."
Hi there, what's the next step here? Does this sort of change need to be pushed through by someone in particular or approved by a critical mass before we can proceed, or would making the changes I proposed above be something I could pursue myself? (Clearly I've never done this before!)
@emilyanndavis Anybody can propose a change to FCC's source code if they want to. Usually for minor, non-critical changes, FCC's team leaves it up to contributors such as you and me to submit a pull request for someone on the team to review.
The team seems to be quite busy implementing some major features and improvements to FCC right now so a minor issue such as this is likely to be near the bottom of their list of priorities to work on themselves.
If you want to submit a change to the source code (pull request) yourself, check out this Contributors Guide. It's an awesome feeling knowing you've contributed something to a major project.
Tip if you're interested in contributing: Once you have a local copy of FCC's repository, you'll find the descriptions of this challenge in freecodecamp/seed/challenges/01-front-end-development-certification/basic-javascript.json
. Make sure you review the Contributors Guide first before making any local changes.
You can find a more detailed guide to making changes here which includes an example. Also, if you ever get stuck, check out the Help Contributors Chat.
@emilyanndavis And not just to put this all on you. I definitely think you have a valid point. The main thing we need is to come to some consensus on what the revised language needs to be. I'm currently up to my elbows in a sea of bees so I have not had a chance to bounce around new ideas. That's why we have this issue open. I was hoping more folks would chime in with some proposed verbiage.
No worries!
I would be glad to dive in and submit a pull request on my own (@alistermada , thank you so much for summarizing the process and linking to resources!) but I am just as happy to wait until others are on board.
Obviously, I don't expect this to rank highly in terms of critical fixes (since by most definitions it's really not even broken). I just wanted to make sure I hadn't dropped the ball... or, like, not even noticed the ball was in my court. Thanks for leaving the issue open—I will sit tight until we have enough voices to craft something together. Good luck with those bees (watch out for their knees).
The challenge Logical Order in If Else Statements would, I think, be more effective with some additional explanation.
After a brief intro followed by the code for the two functions foo(x) and bar(x), we read:
Then, with no further ado, the Instructions are given:
While there is nothing wrong with the instructions in and of themselves, the use of the word correct in "return the correct statements" implies that the result of one of the example functions was incorrect. And while we might reasonably say one of the results was not the expected or desired result, we should also reasonably admit that 0 is both less than 1 and less than 2 (i.e., both statements are correct).
I would suggest something along the lines of the following, to be added after the sample results of foo and bar, and before the Instructions:
(Actually, I'm not sure "loop" is the best word there, even though it is used in the existing text for this challenge. Could someone weigh in on whether it is appropriate to use "loop" when describing series of if else statements (rather than, say, a for loop)? In any case, at this point loops as a concept have not yet been explicitly introduced in the material.)