Guess The Gifts!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
function guessGifts(wishlist, presents) {
var possible = [];
var toy,box;
for(k=0; k<wishlist.length; k++){
toy = wishlist[k];
for(i=0; i<presents.length; i++){
box = presents[i];
if(box.size==toy.size && box.clatters==toy.clatters && box.weight == toy.weight){
if(possible.indexOf(toy.name)===-1){
possible.push(toy.name);
}
}
}
}
return possible;
}