diff --git a/exercises/concept/fruit-picker/.docs/hints.md b/exercises/concept/fruit-picker/.docs/hints.md index 60894553ac..bf33da9664 100644 --- a/exercises/concept/fruit-picker/.docs/hints.md +++ b/exercises/concept/fruit-picker/.docs/hints.md @@ -4,34 +4,28 @@ - Callback functions are functions passed as an argument to a calling function. - Callback functions must meet the specification of the calling function. -- These callbacks are all synchronous, meaning they all must return a value. -## 1. Check if the grocer's service is online +## 1. Notify with a successful message -- Use the imported API function `checkStatus` in your function. -- Pass a callback function to `checkStatus`. It should expect to receive a string argument. -- Return the result from the `checkStatus` API function. +- Use the imported API function `notify` in your function. +- Pass an object to `notify`. It should have a property of `message`. Think about what the message value should be. +- Pay attention to the JSDoc type hint -- the function should not return a value. -## 2. See if the grocer has some fruit +## 2. Notify with an error message -- Use the imported API function `checkInventory` in your function. -- Create the query _object_ to pass as an argument. - - Follow the template in the instructions. -- Pass along the callback function to the `checkInventory` API function. -- Return the result from the `checkInventory` API function. +- Use the imported API function `notify` in your function. +- Pass another object to `notify`. It should have a property of `message`. The message value should differ from the last part. +- Pay attention to the comments [JSDoc] above the function definition: + - The function should not return a value. -## 3. Create a callback to buy fruit if the inventory is available +## 3. Place an order to buy fruit -- If the `err` argument is not null, throw a new error using `err`'s message. - - See [Error()][mdn-error-constructor] -- if the `err` is null, ignore it and just respond to the value of `isAvailable` - - This pattern is sometimes called a [`Node.js`-style callback][node-js-callback]. -- Return the action determined by `isAvailable` +- Use the already imported `order` function. +- Pay attention to the JSDoc type hints -- the function should receive 3 arguments and not return a value. +- Reuse the previously created callbacks as arguments to the order function. -## 4. Put it all together +## 4. Refactor your work into a more concise function -- Reuse the functions you have already written, composing them together. -- Return the value of the callback function. - -[mdn-error-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error -[node-js-callback]: https://nodejs.org/en/knowledge/getting-started/control-flow/what-are-callbacks/ +- Reuse the functions from the previous tasks. +- Pay attention to the JSDoc type hints -- the function should receive 2 arguments and not return a value. +- Combine the arguments into an object representing the query to the grocer to place an order.