Skip to content

Instantly share code, notes, and snippets.

@Jlawlzz
Last active March 21, 2016 02:13
Show Gist options
  • Save Jlawlzz/184e51ae7611695d19f0 to your computer and use it in GitHub Desktop.
Save Jlawlzz/184e51ae7611695d19f0 to your computer and use it in GitHub Desktop.

##Leap

My code: (here)

Responder #1 (here) - This responder took the approach I first did, a single if else statement. I think this approach works fine for the task at hand and is certainly simpler than mine. Makes me wonder if I over-engineered my approach.

Responder #2 (here) - This user took a unique approach to this problem from what I have seen, using the boolean logic in a long chain attached directly to the return. While I do think this approach is efficient, I wonder about the readability of this approach.

Responder #3 (here) - This person went for a nested conditional approach. I try and stay away from a nested conditional as they can usually be broken out, and things can get hairy. As with the first user I think this apporach is fine for the task at hand. It re-affirms that I may have written too much code.

Responder #4 (here) - This responder also took the nested conditional approach. It is different than the first apporach in that it did not allow boolean logic to take some of the weight off the if else conditioinals. This causes the code to become super elongated, fullfilling the issue that nested conditionals can have. I prefer the third responders nesting to this ones.

Responder #5 (here) - This user broke apart their logic into seperate functions making the code incredibly readable. I think I like this approach the best. It informs my approach to further break the logic down. Rather then within, the logic should live outside of the Year.prototype function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment