[exercises/concept/fruit-picker] Exercise requires users to be familiar with the throw statement
See original GitHub issueWhile I was doing the exercise myself (which is made to test users about the Arrow functions
and Callbacks
concepts), I came across something that I found a bit confusing: task 3 of this exercise requires users to
[…] throw a new error if
err
is not null.
This implies using the javascript throw statement as part of the function the exercise asks you to build. However, the Errors
concept (where the throw
statement is developed) is to be found much further down the syllabus tree, and the way the instruction is described in the task might make users think that “throwing an error” just means returning a string with an message with an error text as opposed to using the error
statement. This is what I did myself, which meant that when running the tests, I got a message from the debugger saying that I was supposed to use something I didn’t even know existed to complete the exercise.
I believe this can be easily fixed by either:
- Making sure the instruction of the task is clear about what the user needs to use (the
error
statement). An easy fix to this would be to add a link to its MDN page in the very same paragraph. - Removing the need to use such statement. This would imply modifying the exercise so that users are required to simply return a string with an error message instead.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hello, in Task 3 it says “Finish the purchaseInventoryIfAvailable callback function to be used with the grocer’s checkInventory API function.”, but the checkInventory callback takes a query and a callback. I’m confused as to how I’m to use checkInventory in this exercise.
@pikkus I agree the introduction could probably be improved. I am not sure what would be gained by decoupling callbacks from arrow functions though. You are already free to choose to not do the
Callbacks
exercise but instead first proceed down theClasses
path in the syllabus. But in the end callbacks are needed to understand all of the array utilities (map
,forEach
,filter
, etc.) in the next “layer” of the concept tree and those are also one of the most common use cases for arrow functions and one reason arrow functions were added to the language. That’s why I think it makes sense to learn about callbacks and arrow functions in the same exercise.