Published
Edited
Oct 22, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
filtered = cars.filter(d => {
var selected = origin;
var min = parameters.minHP;
var max = parameters.maxHP;
return d.Origin == selected && d.Horsepower >= min && d.Horsepower <= max;
}).sort((a,b) => {
return b.Weight_in_lbs - a.Weight_in_lbs;
}).slice(0,20);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
filtered.forEach(function(item) {
let li = document.createElement("li");
li.appendChild(document.createElement("b")).appendChild(document.createTextNode(item.Name + ": "));
li.appendChild(document.createTextNode(item.Cylinders + " cylinders"));
li.appendChild(document.createElement("br"));
document.getElementById("myList").appendChild(li);
});

// Hi Anton! My code sort of worked, but my problem was that it just keeps adding to the list every time another code block runs, so I end up with a giant list. Is there a way to make this method work, so the list resets? Your method is much cleaner, but I'm wondering if I could have found a way to make my method work!
Insert cell
Insert cell
Insert cell
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