Skip to content

Instantly share code, notes, and snippets.

@scottfirestone
Last active May 14, 2016 01:37
Show Gist options
  • Save scottfirestone/7306efba5def2616db33db1031d89817 to your computer and use it in GitHub Desktop.
Save scottfirestone/7306efba5def2616db33db1031d89817 to your computer and use it in GitHub Desktop.
Mod 4 Prework - JS Exercism solutions compared

##Leap My Code

  • Responder #1 - This solution uses a single line and implied conditional (i.e. a return statement for truthiness or falseiness) rather than a nested if/else with explicit true / false returns. I'm thinking this is a preferrable, cleaner approach.
  • Responder #2 - This is similar to my solution but checks the divisible by 4 and 100 logic in the same if branch rather than separating. Slightly cleaner (less branches) than my solution and probably preferrable.
  • Responder #3 - This solution uses 4 functions - 3 that define each rule and 1 that runs all 3; the return value from the master function determines if the input is a leap year or not. Very novel solution - I'm curious if this is 'good' or not.
  • Responder #4 - This solution defines a constant and a class, and I have no idea if it's appropriate given these concepts are all new to me :-/
  • Responder #5 - This solution is identical to the first, above, puting all logic on a single line and storing the truthiness as a return value of the function. Clean, I like it.

##Hamming My Code

  • Responder #1 - This solution is fairly similar but defines another separate var and function for distance and calculating distance. I suppose it's better factored - modularized - but I'm not sure it's necessarily better.
  • Responder #2 - This solution is almost identical except the error is thrown without if/else branching. This makes sense - the branching isn't necessary if the error-throw is first. This would be an easy/quick improvement to my code.
  • Responder #3 - This solution does a lot of input manipulation that seems unnecessary. I don't like it one bit.
  • Responder #4 - Basically the same as solution #2, an easy fix to my code.
  • Resopnder #5 - A similar solution to my code except the strand length is set to a var. A simple refactoring that would benefit my solution, too.

RNA Transcription

My Code

  • Responder #1 - This solution pushes to an array and joins at the end. I prefer my use of concatonating a string.
  • Responder #2 - Very concise but also somewhat difficult to read.
  • Responder #3 - Pretty much the same as my solution.
  • Responder #4 - A lot of if/else branching. I prefer my loop and string concat method.
  • Responder #5 - Very similar to my solution though it's all wrapped in one function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment