You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//this line of code checks if function is provided
if(!func){
//this line of coded iterates through each element in the collection
for(varitemofcollection){
//this line checks if element is false
if(item){
//return false if at least one element is false
returnfalse;
}
}
//returns true if all elements are true
returntrue;
}
//this line checks if colllection is an array
if(Array.isArray(collection)){
//iterates through each element of the array
for(leti=0;i<collection.length;i++){
if(!func(collection[i],i,collection)){
returnfalse;
}
}
}elseif(typeofcollection==="object"){
//iterates through each property in the obj
for(varkeyincollection){
//checks if property is directly on the obj
if(collection.hasOwnProperty(key)){
//calling the function with the correct arguments
if(!func(collection[key],key,collection)){
returnfalse;
}
}
}
}
returntrue;
}
@khamal22, your tests aren't passing for _.extend. I'm not really sure why you're using func as the parameter - the expected arguments for _.extend are an object, and any number of other objects.
A couple things you'll want to research to help implement a solution to this problem:
How do we handle an unknown number of arguments?
Which method can be used to copy properties of one object to another?
The text was updated successfully, but these errors were encountered:
underpants/underpants.js
Lines 569 to 605 in 8f52447
@khamal22, your tests aren't passing for
_.extend
. I'm not really sure why you're usingfunc
as the parameter - the expected arguments for_.extend
are an object, and any number of other objects.A couple things you'll want to research to help implement a solution to this problem:
The text was updated successfully, but these errors were encountered: