Currently, I am working with a dataset where each person is matched with specific shopping items they have purchased. For instance, Joe bought Apples and Grapes.
To gather this information, individuals need to indicate whether they have made a purchase. I typically ask, "Did you buy something? (Apples, Grapes, etc)" and provide Radio Button Options for "Yes" or "No".
If Bob confirms he bought Apples but not Grapes, I aim to derive an overall response for Bob. The final answer should be "Yes," as he did make a purchase.
Here is the code snippet I have been using:
exports.getOverallAnswer = function(boughtSomething){
var answer = ["Yes", "No"];
var scores = [5,4];
var highScore = Math.max.apply(Math,scores);
var scoreIndex = scores.indexOf(highScore);
var answerName = answer[scoreIndex];
return answer;
};
I am struggling to integrate this code with the values of apples and grapes attributed to each individual. Any assistance on how to accomplish this would be greatly appreciated! Thank you in advance!