Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Replace this...
- var out = "mt-aether";
- i = aether;
- if (item > i) { out = "mt-item"; i = item; }
- if (glyph > i) { out = "mt-glyph"; i = glyph; }
- if (potion > i) { out = "mt-potion"; i = potion; }
- if (incantation > i) { out = "mt-incantation"; i = incantation; }
- // with this:
- var out = resultPage(
- [aether, item, glyph, potion, incantation],
- ["mt-aether", "mt-item", "mt-glyph", "mt-potion", "mt-incantation"])
- // and place this into quiz-question-engine.js:
- function resultPage(scoreArray, pageNames) {
- // Find the page that corresponds to the largest score.
- // If multiple pages have the same score, then choose the leftmost one.
- var runningTotal = -Number.MAX_VALUE;
- var runningTotalIndex = 0;
- for (var i in scoreArray) {
- if (scoreArray[i] > runningTotal) {
- runningTotal = scoreArray[i];
- runningTotalIndex = i;}}
- return pageNames[runningTotalIndex];}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement