Skip to content

Instantly share code, notes, and snippets.

@SteveOscar
Created March 15, 2016 20:51
Show Gist options
  • Save SteveOscar/3a3b9f54570014b43234 to your computer and use it in GitHub Desktop.
Save SteveOscar/3a3b9f54570014b43234 to your computer and use it in GitHub Desktop.
JavaScript Exercisms

Leap

My Code

Other Solutions

  1. Solution 1 - This solution is similar to mine in how the person used the logic without an if/else statement, but the groupings of the && and || statements is different. But it produces the same results.
  2. Solution 2 - This person used a baseline false return, which seems unnecessary as long as the code covers and required possibilities. This person also used if/else statements, which is not needed.
  3. Solution 3 - This person did not complete the exercise, as they have only checked for divisibility by 4, and have not create an isLeap function.
  4. Solution 4 - This person used the same basic logic that I used, also choosing to not use an if/else statement. They used a Year class and constructor, with the isLeap function inside, which I do not understand.
  5. Solution 5 - This solution is the same as mine, except there are a couple extra sets of parentheses thrown into the logic.

Hamming

My Code

Other Solutions

  1. Solution 1 - This solution's logic is similar to mine, but the compute method was defined inside of the function, which makes more sense to me.
  2. Solution 2 - This solution is very long (29 lines to my 12) because it uses a while loop, and has an unnecessary if/else for the error detection.
  3. Solution 3 - This soluction is longer than it needs to be because it splits the strings up before iterating through them, but the same can be acheived with just accessing the strings via index in a counter.
  4. Solution 4 - Same situation as the previous solution ^^^
  5. Solution 5 - And again this person called the split method on the inputs, which isn't needed. Also, the variable names are ambigious.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment