Created
August 27, 2024 04:55
-
-
Save Vampeyer/c15fc6620b0386a2507955fd9e1c2cbb to your computer and use it in GitHub Desktop.
JavaScript Kata 6 clean or dirty w thresh holds ratio
This file contains hidden or 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
let samples = ['clean','clean','clean', 'dirty' , 'dirty'] | |
// function checkAir(air){ | |
let dirties = 0; | |
let cleans = 0; | |
let threshhold = 0.75 | |
let returnRatio = 0 | |
function airIntake(samples , threshhold){ | |
for (let i in samples){ | |
// console.log(air[i]) | |
if (samples[i] === "clean"){ | |
cleans += 1 | |
} | |
if (samples[i] === "dirty"){ | |
dirties += 1 | |
} | |
} | |
console.log(" so you have :" , cleans, " clean and ,") | |
console.log(dirties , " dirties ") | |
returnRatio = cleans / dirties | |
console.log( " return ratio here is " ,returnRatio) | |
console.log( " Threshdoler " , threshhold , " ratio " , returnRatio ) | |
if(returnRatio <= threshhold){ | |
console.log("the air is dirty "); | |
} else if(returnRatio > threshhold){ | |
console.log("that there air was clean ") | |
} | |
} | |
airIntake(samples , threshhold) | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment