Merge pull request #3596 from FreeCodeCamp/fix/500-out-of-range-bug

Fix 500 out of range bug when completing last challenge
This commit is contained in:
Quincy Larson
2015-10-05 22:15:26 -07:00

View File

@ -180,9 +180,9 @@ module.exports = function(app) {
'could not find challenge block for ' + challenge.block
);
}
const nextBlock$ = blocks$.elementAt(blockIndex + 1);
const firstChallengeOfNextBlock$ = nextBlock$
.map(block => block.challenges[0]);
const firstChallengeOfNextBlock$ = blocks$
.elementAtOrDefault(blockIndex + 1, {})
.map(({ challenges = [] }) => challenges[0]);
return blocks$
.elementAt(blockIndex)
@ -211,6 +211,9 @@ module.exports = function(app) {
});
})
.map(nextChallenge => {
if (!nextChallenge) {
return null;
}
nextChallengeName = nextChallenge.dashedName;
return nextChallengeName;
})