Public
Edited
Jun 15, 2023
2 forks
Insert cell
Insert cell
viewof period = Inputs.radio(["One-year","Two-year"], {label:"Rent period", value:"One-year"})
Insert cell
viewof rent = Inputs.range([500, 6000], {label: "Current monthly rent:", step: 50, placeholder: "$USD 100 to $6,000"})
Insert cell
newrent = {if (period == "One-year") {
return [Math.round(0.02*rent), Math.round(0.05*rent)];
} else if (period == "Two-year") {
return [Math.round(0.04*rent), Math.round(0.07*rent)];
}
}
Insert cell
Insert cell
function text(){
const p = document.createElement("p");
p.appendChild(document.createTextNode("Your monthly rent could increase by between "));
p.appendChild(document.createElement("b")).appendChild(document.createTextNode("$"));
p.appendChild(document.createElement("b")).appendChild(document.createTextNode(newrent[0]));
p.appendChild(document.createTextNode(" and "));
p.appendChild(document.createElement("b")).appendChild(document.createTextNode("$"));
p.appendChild(document.createElement("b")).appendChild(document.createTextNode(newrent[1]));
p.appendChild(document.createTextNode(" per month."));
return p;
}
Insert cell
viewof output = text()
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