I have an array of symptoms and a min num of symptoms that the person can get for considering if he is sick or not.
this is an example :
var symptoms = ['fever', 'dry cough', 'tiredness', 'sore throat', 'diarrhoea', 'loss of taste', 'loss of smell'];
// var covidDetector = closureDetect(symptoms, 3);
// var personOne = {
// name: 'Franco',
// age: 26,
// symptoms: ['fever', 'congestion', 'loss of taste', 'tiredness']
// }
// var personTwo = {
// name: 'Toni',
// age: 30,
// symptoms: ['congestion', 'tiredness']
// }
//
// covidDetector(personOne); --> true
// covidDetector(personTwo); --> false
and i have this code so far but doesn’t seems to work and idk why:
function closureDetect(symptoms, min) {
return function (person) {
if (person.symptoms.length >= min) {
return true;
} else {
return false;
}
};
}
its all using closures