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
#TimeMemoryFunctionLocation
10.0002361088{main}( ).../index.php:0
20.0040442936require( '/home/prototurk.com/public_html/app/controller/demo.php' ).../index.php:101

Prototürk'e geri dön
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
    }, [])
)