Skip to content

Instantly share code, notes, and snippets.

@patrickwhardy
Last active June 24, 2016 17:03
Show Gist options
  • Save patrickwhardy/25f02b104fa8a2ae3dc06972220a2a7e to your computer and use it in GitHub Desktop.
Save patrickwhardy/25f02b104fa8a2ae3dc06972220a2a7e to your computer and use it in GitHub Desktop.
Javascript Exercisms Comparison

##Leap My code: here

  • Responder #1 (Matt P) here
  • Looks like Matt implemented the same solution as me: checking if the year is divisible by for then an && statement to ensure the year isn't a century or that it can be every 4 centuries.
  • I don't like how nested this person's solution became. In fact - I wonder if this is actually passing because the last return false does not seem to be nested inside of a conditional and should always return.
  • I like the flexible chkMod method that this person wrote. Passing in the divisor as an argument is a creative solution that only need modified with a ! operator to make sure its not a century. Otherwise the format is much the same.
  • This person had almost the same solution, but nested the two positive assertions on the left side of the && operator. I think this is more clear and prefer it.
  • This person also wrote a highly nested conditional. Also, she is console logging "true" strings instead of returning the boolean so I'm not sure if this one would actually pass either.

##Hamming My code here

  • This person provided a concise single method solution. Otherwise, the basic approach of this is very similiar to my own.
  • This is a bit nested. Where I pulled out a helper method, this person just ran code in the else statement. Very similiar to my own.
  • This person's solution is very concise. They were able to complete everying thin a single if conditional and for loop
  • This is very similiar to the last response, but the error is thrown from the else side of the condition.
  • This person also solved this with a single conditional and for loop. It's interesting that this person set distance to string length and subtracts when the are the same. This seems counter intuitive to me, and requires more computation than adding when they the value at a given index is different.

##Bob My code here

  • This person uses trim instead of filtering out whitespace with regex for the "Fine be that way" response. This is a nice method that seems easier than writing out the regex.
  • This person also used trim. One thing I don't understand so well is their use of const. This seems quite complicated for what is being accomplished.
  • This person did pretty much the same thing as me. One interesting thing here is returning the response inline with the conditional. This makes it look more concise, but maybe harder to read.
  • This persons response is very, very long. It appears to accomplish the same thing but uses many breaks and cases which do not seem necessary.
  • This is very concise and probably the best solution of the bunch. I like the use of the charAt method, which I have not seen before and seems very efficient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment