-
Notifications
You must be signed in to change notification settings - Fork 12
Errata
Michael Rosata edited this page Oct 16, 2017
·
2 revisions
Below are some known errata in the Mastering Functional Programming with JavaScript course by Packt Publishing.
The every
and some
functions don't apply the predicate function over the last element in the arrays being tested. Thanks to for @invegat for pointing this and providing a fix. The videos will be updated soon as well.
Here is the every
function fix
function every(predicate, list = []) {
if (list.length) {
const [item, ...remaining] = list
return predicate(item) ? every(predicate, remaining) : false
}
return true
}
And here is the updated some
function
function some(predicate, list = []) {
if (list.length) {
const [item, ...remaining] = list
return predicate(item) ? true : some(predicate, remaining)
}
return false
}