Last active
June 14, 2023 16:53
-
-
Save crhallberg/af9f0b8b30753c63e5df4b16a5e7b271 to your computer and use it in GitHub Desktop.
Falvey 2023: Intro to Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Hello, Falvey!!"); | |
// JS will ignore this | |
let MULCH = 2; | |
let INCHES_IN_A_YARD = 36 * 36 * 36; | |
function doCalculations(garden) { | |
// We want 2 inches of mulch | |
garden.mulchDepth = MULCH; | |
garden.compostDepth = garden.fillDepth - MULCH; | |
// UNLESS we have 2 inches or less | |
if (garden.fillDepth <= MULCH) { | |
garden.mulchDepth = 1; | |
garden.compostDepth = garden.fillDepth - 1; | |
} | |
garden.mulchYards = garden.width * garden.length * garden.mulchDepth / INCHES_IN_A_YARD; | |
garden.compostYards = garden.width * garden.length * garden.compostDepth / INCHES_IN_A_YARD; | |
console.log("Mulch Volume", garden.mulchYards); | |
console.log("Compost Volume", garden.compostYards); | |
console.log(); | |
return garden; | |
} | |
// Back Wall – Beans 19 32 2 | |
let beanBed = { | |
name: "Bean Bed", | |
width: 19, // inches | |
length: 32, // inches | |
fillDepth: 2, // inches | |
}; | |
// Box 1 – Tomatoes 57 137 5 | |
let tomatoBox = { | |
name: "Tomato Box", | |
width: 57, // inches | |
length: 137, // inches | |
fillDepth: 5, // inches | |
}; | |
let gardenList = [ | |
beanBed, | |
tomatoBox, | |
]; | |
gardenList.forEach(doCalculations); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Garden Project: https://docs.google.com/spreadsheets/d/1lo5OIHz9ludqh7hzxoY7NaVxQf6_6yWoQLuUoeVjgYA/edit?usp=sharing