Skip to content

Instantly share code, notes, and snippets.

@julyytran
Last active May 5, 2016 22:58
Show Gist options
  • Save julyytran/9ea02008c93f705d61e361be7e2c636e to your computer and use it in GitHub Desktop.
Save julyytran/9ea02008c93f705d61e361be7e2c636e to your computer and use it in GitHub Desktop.
JS exercism comparisons

My code

##Leap

  • Responder 1 This person used nested ifs and return true/false. I think condensing the if statements into one makes for cleaner code, and it will already return true/false based on how it evaluates, so you wouldn't need to explicitly state it.
  • Responder 2 This person has an if/else if/else structure where the if and else if both return true. They could condense that into one statement to DRY it out a bit, and assign it to a variable to get rid of the if/elses.
  • Responder 3 This person did it the same way I did! I think it's a great implementation.
  • Responder 4 This person has a 4 branch if/else statement. The branches that return the same value can be condensed with a joint conditional.
  • Responder 5 Similarly to others, this person has a branched if/else where some branches share outcomes. They can be combined with an or operator.

##Hamming

  • Responder 1 This person did it the same way as me, except for declaring strand length as the length of one of the args, and then checking if strand length was equal to the arg length. I would just check the length of the two args against each other.
  • Responder 2 This person did it the exact same way as me. I think it looks great.
  • Responder 3 This person also did it the same way.
  • Responder 4 This person did not use Hamming.prototype and instead uses this.compute and a nested function. They also use distance++ instead of distance += 1. I don't know enough about prototype or how 'this' is used here to comment on why one would be preferable over another. I guess if you don't really know what prototype means 'this' might make more sense. I like the use of ++ instead of +=1. It looks cooler, albeit less explicit.
  • Responder 5 This person did it the same way I did as well.

##RNA Transcription

  • Responder 1 This person used if/else if branching instead of an object. I think an object makes for more consice and clearer code.
  • Responder 2 This person maps the split characters from the DNA string to a new array of its complements and joins it back to a string. I think this is pretty cool, but maybe use of if/else to return the complement can be done by creating and accessing an object instead for consiceness.
  • Responder 3 This person did it the same way as I did, but directly with the string input. I had changed it to an array because I thought the loop would only work with an array.
  • Responder 4 This person created a replacing function within the transcription function that creates an object and accesses it in the return line all at once. Pretty cool. Not totally sure what's going on in line 8 though.
  • Responder 5 This person added to the total string the result from an if/else statement to match the complements. I think combining the setting of complements with the action of the transcription is interesting, but I still prefer use of an object to make the logic clearer and avoid long if/elses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment