function filter(array, test) //on definit ce qu'est un filtre.
{
var passed = [];//initialiser l'accumulateur.
for (i = 0; i < array.length; i ++)//c'est accumuler
//a partir d'une liste en posant un test de critere d'accumulation.
{
if (test(array[i]))
{
passed.push(array[i]);//incrementer l'accumulateur.
}
}
return passed;
}
console.log(filter([0,10,1,2,3,4,5,6,7,8,9], function(numb)
{//definir le test.
return numb > 3;
}
)
);
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.