filter()
ve map()
yerine reduce()
kullanmak
( ! ) Notice: Undefined index: description in /home/prototurk.com/public_html/app/controller/demo.php on line 171 Call Stack # Time Memory Function Location 1 0.0002 361088 {main}( ) .../index.php:0 2 0.0040 442936 require( '/home/prototurk.com/public_html/app/controller/demo.php' ) .../index.php:101
const numbers = [-5, 6, 2, 0,]
console.log(
numbers
.filter(number => number > 0)
.map(number => number * 2)
)
console.log(
numbers.reduce((acc, number) => {
if (number > 0){
acc.push(number * 2)
}
return acc
}, [])
)