//AURAIS_JE REUSSI? OUAIS!!!!!!!!!!
function where(collection, source) {
var arr = [];
// What's in a name?
liSou = Object.keys(source);
//console.log("liSou = ", liSou, '\n');
for (i = 0; i < collection.length; i ++) {
var Hefets = collection[i];
//console.log('Hefets = ', Hefets, '\n');
var interSect = [];
//console.log('inttersection initiale: ', interSect, '\n');
for (j = 0; j < liSou.length; j ++) {
kinouye = liSou[j];
console.log("kinouye = ", kinouye, '\n');
console.log('Hefets[kinouye] = ', Hefets[kinouye]);
console.log('source[kinouye] = ', source[kinouye]);
if (Hefets[kinouye] !== undefined && Hefets[kinouye] !== null &&
source[kinouye].toString() == Hefets[kinouye].toString()) {
/*console.log('source['kinouye'] et Hefets['kinouye']',
source[kinouye], ' et ', Hefets[kinouye], '\n');*/
//each of them return undefined, why?
interSect.push(kinouye);
console.log("interSect = ", interSect, '\n');
}
if (interSect.toString() == liSou.toString() ) {
arr.push(Hefets);
//console.log('la source est inclue');
}
//console.log('arr = ', arr, '\n');
}
}
return arr;
}
where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 })
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.