I have a function named uncompletedSteps():
function uncompletedSteps(completedSteps) {
// completedSteps is an array
}
This function should examine completedSteps and return the index of all completedSteps elements that are not equal to true:
if (completedSteps[i] === true) {
// add to return list
}
In other words, if have:
var completedSteps = [
true,
null,
true
];
Then uncompletedSteps() should return [0, 2].
What should this uncompletedSteps() look like? (ECMAScript5 okay.)
Using
reduce:Using
forEach:Using
mapandfilter