Skip to content

Instantly share code, notes, and snippets.

@natevenn
Last active May 9, 2016 00:41
Show Gist options
  • Save natevenn/6fa10f5f7e72251ea9d43e27a9751ce8 to your computer and use it in GitHub Desktop.
Save natevenn/6fa10f5f7e72251ea9d43e27a9751ce8 to your computer and use it in GitHub Desktop.

##Leap

my code

responder 1 this person created variables for each calculation and then calls on that variable in the conditional. This is probably good practice for more complicated nested functions but for this problem I dont think its necessary

responder 2 this person kept it simple and evaluated the parameter using && and or operands, similar to me. They kept it very simple by just returning the evaluated statement and saved a couple of lines I could easily refactor mine the same way.

responder 3 this person's solution is like a combination of the previous two he created varables for each statement but kept it simple by returning if true or false by using && and or. They used the prototype to inherit

responder 4 this person use the if else if and else branchs to evaluate. I only used the if and else but could easily just return the statement and if true true and by default return false if not true

responder 5 this person creates a seperate function called divisibleBy to evaluate if yeap. Since there are just 3 static factors I dont think its necessary to create the divisibleBy function but if that facotr could change then it makes sense

##Hamming

my code

responder 1 this person has a very similar solution but could simplify by not including a condition for when the two strands are equal. I think JS will by default just move to next letter if there is no code for dealing with when they are equal, since we dont need to do anything when they are equal.

responder 2 this person went down the road of splitting the strings and then iterating thru with a forEach. In JS the strings are already index and therefore just need to loop thru each index of the string.

responder 3 this person instead of counting each occurance of when strands are no the same, they push it into an array and then call .length on the array to get the total count.

responder 4 this person used let instead of var to set variables. Do they need to scope it to the block or is function scope enough?

responder 5 this person uses a prototype that inherits from the Hamming function. What is there to inherit from can you just call this.function inside of the scope. Im not sure the difference.

##rna-transcription

my code

responder 1 this person initiates an empty string and then adds all the characters that are the compliments. I like this better than initiate and empty array and then push and then join. Instead of creating a JS object with the compliments they used a case statement.

responder 2 this person maps over the dna parameter and then calls join on the end. This is very similar to how I might approach it in ruby. Im glad to see how similar JS and ruby can be.

responder 3 this person had a similar solution as me. Again I like the use of adding to an empty string instead of a array. It saves from having to turn the array back into a string. Im my solution I set a variable to the parameter index value and then passed the variable as a property on the dna to rna object to get the value. But this person just skipped the step and although not necessary, I think it makes it more readable.

responder 4 this person accounts for errors even though the spec does not test for it. I think that this is good practice. They also used a long if/else if branch that accounts for all the differenct inputs. I actually think that is reads fine and might be less confusing than creating a object with properties like I did. But it makes the code longer and less succint

responder 5 this person splits then maps and then uses the case statement to return its compliment and then joins. I find this clean and easy to read. Its so familiar to ruby unlike the for loop that I used. Good to know that it can be done this way. Although I am not familiar with the JS switch statement

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