Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Created December 17, 2014 02:25
Show Gist options
  • Save Sigmus/abff692bc8069b35c0c2 to your computer and use it in GitHub Desktop.
Save Sigmus/abff692bc8069b35c0c2 to your computer and use it in GitHub Desktop.
A Beautiful Function
var handleCheckAlternative = function(result) {
var playSound = playWrongAudio;
var after = renderInfos;
if (isLastQuestion(result)) {
after = _.compose(renderPoints, quizOver);
}
if (result.correct && isLastQuestion(result)) {
playSound = playTouchdown;
}
else if (result.correct) {
playSound = playCorrectAudio;
after = _.compose(renderNextQuestion, after);
}
playSound(_.partial(after, result));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment