I'm putting together a quiz with A/B questions. Every answer has 5 parameters that have to be updated as the user advances through the quiz to show a final results page.
It's very simple but I can't figure out why the parameters aren't updating. This is my first Javascrips project, can somebody point me in the right direction? Thank you!
//The five parameters to be updated
let totalOrg = 2;
let totalDel = 2;
let totalMod = 0;
let totalLux = 2;
let totalSer = 2;
// Array with values to modify the parameters for A or B answers
var valueDataA = [
[1,2,5,1,3],
[6,5,1,2,8]
];
var valueDataB = [
[-6,-3,-7,-3,-2],
[-1,-7,-5,-2,-3]
];
//Function to add the values to the parameters
function chooseOptionA() {
totalOrg = totalOrg + valueDataA[currentQuestion][0];
totalDel = totalDel + valueDataA[currentQuestion][1];
totalMod = totalMod + valueDataA[currentQuestion][2];
totalLux = totalLux + valueDataA[currentQuestion][3];
totalSer = totalSer + valueDataA[currentQuestion][4];
console.log(totalParameters);
};
function chooseOptionB() {
totalOrg = totalOrg + valueDataB[currentQuestion][0];
totalDel = totalDel + valueDataB[currentQuestion][1];
totalMod = totalMod + valueDataB[currentQuestion][2];
totalLux = totalLux + valueDataB[currentQuestion][3];
totalSer = totalSer + valueDataB[currentQuestion][4];
console.log(totalParameters);
};
let totalParameters = [totalOrg, totalDel, totalMod, totalLux, totalSer];