Hello!
I have never used JavaScript before and I am now struggling to implement a top 3 question. The question looks like this:
Basically, the participants are asked to do a point distribution game. They need to distribute a certain amount of points across 8 candidates and I would like to show them their top 3 choices (based on participants' own previous point distrubutions) automatically and then ask the participants to make their final choice among the top 3 candidates.
There are two important issues here:
1. The top 3 choices purely depend on participants' own point distributions (i.e., the answers of previous questions). As I do not have fixed numbers, how should I add piped texts into the JavaScript code? My friend suggested me that I might write a code like this:
The logic here is to pick the maximum number from the first array (contains 8 points of all the 8 candidates) and set it as max1 - then remove it and pick the maximum number from array2 (remaining 7 points of 7 candidates) and set it as max2 - then remove it and pick the maximum number from array3 (remaining 6 points of 6 candidates).
The code above is invalid and I have no idea how I could modify it as I do not know JavaScript at all.
2. The second issue is that, instead of the top 3 scores, I need to show participants the top 3 scored candidates' names (not scores!). However, the candidates' names are not fixed as well. The names are randomized using randomizer and embedded data. Therefore, the piped text in the code should correspond to the names appeared in previous questions.
An example of candidate 1 name in previous question:
Could anyone help me with this question? Is there a simple way to solve the problem?
Thanks a lot!
Best answer by bgooldfed
View original