scrimba
JS Deep Dive
Arrays & Sets
Challenge: Transform Arrays with .reduce()
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Challenge: Transform Arrays with .reduce()
AboutCommentsNotes
Challenge: Transform Arrays with .reduce()
Expand for more info
index.js
run
preview
console
// Challenge: 
// Use reduce() to sum the weights of all the cars
// Stretch goal:
// Use reduce to sum the weights of only the electric cars

const cars = [
{ name: "Toyota", isElectric: false, weight: 1320 },
{ name: "Ford", isElectric: false, weight: 1400 },
{ name: "Volkswagen", isElectric: false, weight: 1370 },
{ name: "Honda", isElectric: false, weight: 1375 },
{ name: "Tesla", isElectric: true, weight: 1750 },
{ name: "BMW", isElectric: true, weight: 1350 },
];
Console
8565
,
3100
,
/index.html
-2:34