##Hamming My code: here
I didn't have any responses to this. Now we are getting to the juice. this problem took me a minute to think about how to build, but comparing two strings isn't too difficult. I initially thought I could use indexOf
to compare the chars, but realized I was looking at it backwards.
-
Option #1 (here) - about the only difference other than variable names in this coder's solution was that they just grabbed index
[i]
of each string to compare. slightly more compact, slightly less verbose. -
Option #2 (here) - this coder opted for a shorter ternary, but also included the longer form in commented out code. it's clever, but it also explains to you what is going on. although I think I would have just used the longer code. this amount of verbosity feels like overkill.
-
Option #3 (here) - I like the error call coming last. it should be the least used operation, so that seems like its logical place. however, I wonder how both this solution and mine are working, when I am using
i = 0
andi <= first.length
and they are also usingi = 0
, but then usingi < strand1.length
? it also occurred to me while looking at these solutions that I could have implemented this using a forEach loop.