Skip to content

Instantly share code, notes, and snippets.

@zackforbing
Last active October 11, 2016 00:25
Show Gist options
  • Save zackforbing/7ef033a45b88e64060b88c879a2435de to your computer and use it in GitHub Desktop.
Save zackforbing/7ef033a45b88e64060b88c879a2435de to your computer and use it in GitHub Desktop.
Leap Exercism

##Leap My code: here

I didn't have any responses to this. I also realized after I submitted that I didn't need the first this.year % 100 = 0, but I didn't want to iterate my solution.

  • Option #1 (here) - this coder's solution was to create variables inside the function, which seems a little kludgy, but their return statement looks rather elegant. they could have made it more elegant by making divisibleBy100 into notDivisibleBy100, though.

  • Option #2 (here) - this solution seems like a bit of a mess. the returns aren't in any semblance of order. their first statement is unnecessary - that return false could have been easily returned for the else. however, I can see that it is essentially a guard statement - firing off what should be the most common return first avoids running through the entire if statement every single time.

  • Option #3 (here) - this is quite possibly the cleanest solution available for this. without using ugly ternary syntax, they run through all three of the requirements for the function to return true in one line of code. pretty clean, and easily readible.

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