Skip to content

Instantly share code, notes, and snippets.

@anthonyk1225
Created November 17, 2020 16:50
Show Gist options
  • Select an option

  • Save anthonyk1225/d9dc3dca969086bd1c61ca398897e415 to your computer and use it in GitHub Desktop.

Select an option

Save anthonyk1225/d9dc3dca969086bd1c61ca398897e415 to your computer and use it in GitHub Desktop.
COVID-19 rapid test algorithm
// leaked code for COVID-19 rapid test algorithm
const RapidTest = function(name, age, swabbed, fliched) {
this.name = name;
this.age = age;
this.wasSwabbed = swabbed;
this.flinched = fliched;
}
RapidTest.prototype.isPositive = function() {
const hasCorona = Math.random() <= 0.5;
return hasCorona;
}
RapidTest.prototype.wasABitch = function() {
if (this.wasSwabbed && !this.flinched) return false;
return true;
}
RapidTest.prototype.hasCovid = function() {
const wasABitch = this.wasABitch();
const isPositive = this.isPositive();
if (!wasABitch && !isPositive) return false;
return true;
}
const elonDidntFlinch = new RapidTest("Elon Musk", 49, true, false);
const elonFlinched = new RapidTest("Elon Musk", 49, true, true);
console.log("sample1", elonDidntFlinch.hasCovid());
console.log("sample2", elonDidntFlinch.hasCovid());
console.log("sample3", elonDidntFlinch.hasCovid());
console.log("sample4", elonFlinched.hasCovid());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment