Skip to content

Commit 06ad334

Browse files
committed
array reduce
1 parent 8882ccf commit 06ad334

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

39_array_reduce.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ const produk = [
1111
{ name: 'sony', model: 'android', price: 40000 },
1212
];
1313

14-
let result = produk.reduce(function (acc, current) {
15-
console.log(acc + current.price);
14+
let result = produk.reduce(function (acc, currentItems) {
15+
console.log(`total : ${acc} ${currentItems.price}`);
16+
acc += currentItems.price;
1617
return acc;
17-
});
18+
}, 100000);
1819

1920
console.log(result);
2021

0 commit comments

Comments
 (0)