Public
Edited
Dec 4
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
part1 = {
let collector = 0;
for (let i = 0; i < listA.length; i++) {
const distance = Math.abs(listB[i] - listA[i]);
collector = collector + distance;
}
return collector;
}
Insert cell
part2 = {
let collector = 0;
for (let i = 0; i < listA.length; i++) {
const a = listA[i];

const count = listB.filter((b) => b == a).length;
collector = collector + a * count;
}
return collector;
}
Insert cell

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.
Learn more