#Leap# My code Here
-
Responder 1 here - This responder used an if statement for each of the possible leap year definitions. He also depended on 0 evaluating to false in order to get his ! on each statement to work.
-
Responder 2 here - This responder got down his code to just a single line. His code started similar to mine and then he refactored it down to just return either true or false without the explicit need for an 'if'.
-
Responder 3 here - This responder used two if statements, each evaluated whether the year was divisible by 4 and then he split them based on their divisibility by 400 or 100.
-
Responder 4 here - This responder used a combination of responders 1 and 2, where he got it down to one line and relied on 0 evaluating to false.
-
Responder 5 here - This responder defaulted his function to false, and then provided two if statements for the circumstances that a leap year did occur.
#Hamming#
My code Here
-
Responder 1 here - This responder used a for each loop to go through the first array and then used the index of that array to compare it to the equivelent spot on the second array.
-
Responder 2 here - This responder used the charAt string method to get to the first value in each string. If they matched, they set a counter value from 0 to 1. Then they used recursion to go through the method again with the next value in the string using .substring.
-
Responder 3 here - This responder broke out the job of calculating the difference to a different function from the original compute function and just left the function that checked to see if the strings were the same length.
-
Responder 4 here - This responder refactored a similar solution to mine. He broke out functions to check for equal length, to split the strings to arrays, and to calculate the hamming.
-
Responder 5 here - This responder used a turnary statement to assign either a 0 or 1 value to be added to the hamming counter.
#RNA Transcription#
My Code Here
-
Responder 1 here - This responder used a for each loop like I did but instead of if statements, he used a switch with cases to determine what should be done to each letter.
-
Responder 2 here - This responder had a much more elegant solution than I did. He set up a JSON object as a map to how the letters should be mapped. Then he used a for loop to go through each letter and call the corresponding value in the JSON map and then pushed to a new array.
-
Responder 3 here - This responder had a similar solution to responder 2 except he used a .map on the array of original characters to return a new array that had been matched to the JSON map.
-
Responder 4 here - This responder created 2 arrays, one for the original DNA letters and one for the transcribed RNA letters. He then used a map and indexOf to determine the index of the DNA array and map it to the RNA array.
-
Responder 5 here - This responder used a similar approach as responder 2 but used the 'for (let character of array)' style to iterate through the array which I had not seen before.