Skip to content

Instantly share code, notes, and snippets.

@afg419
Created March 19, 2016 23:16
Show Gist options
  • Save afg419/fd1816a018727e00efe2 to your computer and use it in GitHub Desktop.
Save afg419/fd1816a018727e00efe2 to your computer and use it in GitHub Desktop.
Analysis of a JS exercism

##Leap My code: here

  • Responder #1 (here) - This responder is using Number.isInteger rather than modular arithmetic. Otherwise the if then logic is pretty much identical.

  • Responder #2 (here) - This user extracted the checking of divisibility to its own method. I think it's OK done this way, but I think x % 4 === 0 is pretty readable on it's own.

  • Responder #3 (here) - This user did pretty much exactly what I did. I will say, the alternate way of forming the conditional is a bit harder to read this way, especially because it relies on implicit use of associativity, and frankly, I don't know what that is.

  • Responder #4 (here) - This responder extracted the entire conditional to its own method. It takes in a year as a parameter which allows this method to be used to use in a more general context... On the other hand, the Year class takes in a year as a parameter, and it is hard to imagine this method will ever be used on something besides this.year... and if it did it would be weird.

  • Responder #5 (here) - This responder could completely get rid of the if-else statement (which simply returns true or false respectively)! Otherwise seems maybe a bit overly complicated, but effective.

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