function double (number) { return number*2;}
const numbers = [5, 2, 7, 6];
const doubled = numbers.map(double);
console.log(doubled);
VM2529:1 (4) [10, 4, 14, 12]
const test2 = numbers.filter(double);
console.log(test2);
VM2721:1 (4) [5, 2, 7, 6]
Here what gonna work is the map that what do is apply the rule for each example, and the other how isn't a test would not change nothing, so the filter you see that make an Boolean test, how I didn't make a comparison just did nothing.
Rute Bezerra de Menezes Gondim
No comments:
Post a Comment