Ok, understood.
Let’s say, you have 12 RBGs (12 questions) with 4-options each, representing 4-types of answers. 3-Questions for each of a TYPE.
Each of the 4-possible values (consisting of number 1-4), represent the category where you want to calculate (adding) count-up a number.
The IDs of your Radio-Button-Groups will be…
rbg1
rbg2
rbg3
rbg4
…
…
rbg12
But wait! Isn’t there even a better idea out there?
What about directly deviding your RBGs into different types of a group ?
For example…
rbg1Type2
rbg2Type1
rbg3Type4
rbg4Type3
rbg5Type2
rbg6Type1
rbg7Type3
rbg8Type4
rbg9Type3
rbg10Type4
rbg11Type1
rbg12Type2
Ok, but why do i need this? Let’s sort our created RBG-Types…
Type-1 —> [ rbg2 , rbg6 , rbg11 ] <— typeArray1
Type-2 —> [rbg1, rbg5, rbg12 ] <— typeArray2
Type-3 → [rbg4, rbg7, rbg9] <— typeArray3
Type-4 → [rbg3, rbg8, rbg10] <— typeArray4
What for do i need the definition of types now? ? ?
Well, the types will represent …(here are your 4-types)…
Now you will need a LOOP, to loop trough the TYPE-ARRAY to be able to calculate all data for each type .
Let’s say → TYPE-1 = " LEADERSHIP "
Now someone has chosen options in rbg2 , rbg6 and rbg11
Of course you want now to get the end-result for TYPE-1 .
How high will be the score for type-1 (LEADERSHIP) ???
Let’s do a loop, to find out which score we get for —> LEADERSHIP (TYPE-1)…
We will save the end-result for the TAPE-1-LOOP in a variable called ( endResultType1 )…
let endResultType1 ;
typeArray1 .forEach(element=> {
endResultType1 = endResultType1 + element.value;
});
This will loop through all (3 selected values of —> rbg2 , rbg6 , rbg11 <— and sum them (save them) inside the —> endResultType1 <— variable.
After the loop has finished it’s work → your first result of your related to your first-type-questions has been calculated. Now you know the score for → LEADERSHIP
Doing the same 3-more times for the other TYPES, you will get at least 4 different scores…
SCORE-1 (LEADERSHIP) —> for example 12
SCORE-2 (HELP) --------------> for example 6
SCORE-3 (HOSPITALITY) → for example 4
SCORE-4 (SERVICE) ---------> for example 8
Now you got all your 4-scores you wanted to have.
What next? Find the highest score?
And again you can use a loop, if you convert your fixed result-variables into an ARRAY aswell…
How to do ?
CHANGING our previous code…
instead of → let endResultType1;
we use now ----> let endResults = ; <— defining our endResults as an ARRAY.
Our resulting CODE would be…
let endResults = [];
typeArray1.forEach(element=> {
endResults[0] = endResultType1 + element.value;
});
typeArray2.forEach(element=> {
endResults[1] = endResultType2 + element.value;
});
typeArray3.forEach(element=> {
endResults[2] = endResultType3 + element.value;
});
typeArray4.forEach(element=> {
endResults[3] = endResultType4 + element.value;
});
Let’s generate the whole code, to solve your issue…
We already learned…
$w.onReady(()=>{
});
Going step further and adding the new knowledge… defining the TYPE-arrays.
Since we are using now type-arrays, we don’t need to generate a type-specific element-ID like shown above -->(rbg9Type3)<-- anymore!
Because now we have our Type-Arrays, where we simply add the IDs of the RBGs, corresponding to the right type (questions).
$w.onReady(()=>{
//Type-1 --->
let typeArray1 = [rbg2, rbg6, rbg11]; //for LEADERSHIP
//Type-2--->
let typeArray2 = [rbg1, rbg5, rbg12 ]; //for HELP
//Type-3 -->
let typeArray3 = [rbg4, rbg7, rbg9]; //for HOSPITALITY
//Type-4 -->
let typeArray4 = [rbg3, rbg8, rbg10]; // for SERVICES
});
Going step further…
$w.onReady(()=>{
let endResults = [];
//--------------------------------------
let typeArray1 = [rbg2, rbg6, rbg11];
let typeArray2 = [rbg1, rbg5, rbg12 ];
let typeArray3 = [rbg4, rbg7, rbg9];
let typeArray4 = [rbg3, rbg8, rbg10];
//--------------------------------------
typeArray1.forEach(element=> {
endResults[0] = endResults[0] + element.value;
});
typeArray2.forEach(element=> {
endResults[1] = endResults[1] + element.value;
});
typeArray3.forEach(element=> {
endResults[2] = endResults[2] + element.value;
});
typeArray4.forEach(element=> {
endResults[3] = endResults[3] + element.value;
});
});
Of course the shown code is still not complete, what else did we forgot or did not add into our code? Yes, sure, all our RBGs are still not completely defined, let’s do it…
$w.onReady(()=>{
let endResults = [];
//-------------------------------------
let rbg1 = $w('#rbg1'); //--> ID of Radio-Button-Group
let rbg2 = $w('#rbg2');
let rbg3 = $w('#rbg3');
let rbg4 = $w('#rbg4');
let rbg5 = $w('#rbg5');
let rbg6 = $w('#rbg6');
let rbg7 = $w('#rbg7');
let rbg8 = $w('#rbg8');
let rbg9 = $w('#rbg9');
let rbg10 = $w('#rbg10');
let rbg11 = $w('#rbg11');
let rbg12 = $w('#rbg12');
//--------------------------------------
let typeArray1 = [rbg2, rbg6, rbg11];
let typeArray2 = [rbg1, rbg5, rbg12 ];
let typeArray3 = [rbg4, rbg7, rbg9];
let typeArray4 = [rbg3, rbg8, rbg10];
//--------------------------------------
typeArray1.forEach(element=> {
endResults[0] = endResults[0] + element.value;
});
typeArray2.forEach(element=> {
endResults[1] = endResults[1] + element.value;
});
typeArray3.forEach(element=> {
endResults[2] = endResults[2] + element.value;
});
typeArray4.forEach(element=> {
endResults[3] = endResults[3] + element.value;
});
});
Now we already getting closer to our wished END-RESULT !!! 

What else do you need? What else you already have learned in my last post-answer?
-What about → a button-click, which starts all the process???
-What about → adding some → console-logs?
And do not forget to add 12x RBGs onto your page with the corresponding IDs, like shown inside of the code.
If you go even further, you can shorten this code by 50% , but this would be next level
.
If your friend is a coder → he will understand.
.
Try to complete this code, by adding the last step(s) to get your wished function.
