We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS novice to Ninja >>> node
function mean(array, callback) { ... if (callback) { ..... array.map(callback); ..... } ... ... const total = array.reduce((a, b) => a + b); ... return total / array.length; ... } undefined mean([8, 4, 7, 9], x => x*2); 7 mean([8, 4, 7, 9]); 7
The text was updated successfully, but these errors were encountered:
Sorry for the long delay in replying!
This is because map doesn't mutate the array. The code in the if block needs changing to:
map
if
if (callback) { a = array.map(callback); }
Hope that helps!
Daz cc @simonmackie (to update code in ebook)
Sorry, something went wrong.
No branches or pull requests
JS novice to Ninja >>> node
The text was updated successfully, but these errors were encountered: