Published
Edited
Aug 10, 2019
Insert cell
md`# Coding Challenge - The Farm Problem`
Insert cell
function animals(chickens, cows, pigs) {
let chickenLegs, cowLegs, pigLegs, legTotal;
chickenLegs = chickens * 2;
cowLegs = cows * 4;
pigLegs = pigs * 4;
legTotal = chickenLegs + cowLegs + pigLegs;
return legTotal;
}
Insert cell
animals(2, 3, 5); // returns total leg count based on amount of each animal type...
Insert cell
animals(1, 2, 3);
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