Skip to content

Instantly share code, notes, and snippets.

@Vampeyer
Created August 27, 2024 04:55
Show Gist options
  • Save Vampeyer/c15fc6620b0386a2507955fd9e1c2cbb to your computer and use it in GitHub Desktop.
Save Vampeyer/c15fc6620b0386a2507955fd9e1c2cbb to your computer and use it in GitHub Desktop.
JavaScript Kata 6 clean or dirty w thresh holds ratio
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