sums[sums.length-1]+=+lines[i];// add the snack to the current elf's total
}else{
sums.push(0);// start counting for a new elf
}
}
returnsums;
}
d3.max(calorieSums)// First answer: the highest calorie sum
sortedSums=calorieSums.sort((a,b)=>a-b).reverse()
top3Total=sortedSums
.slice(0,3)
.reduce((accumulator,currentValue)=>accumulator+currentValue)// Second answer: top 3 calorie sums
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.