loading...

re: How to Solve Sock Merchant Code Challenge VIEW POST

FULL DISCUSSION
 

First off, it's a great article. Unrelated but I wrote a code that is something similar to this when developing a game to match a pair of emojis a while ago, so this article really takes me back.

One thing I'd like to point out that in your code (I assume it's Javascript but CMIIW), .sort already mutates the array, so you don't have to reassign it to a variable.

- ar = ar.sort()
+ ar.sort()

Nevertheless I think you got the right idea. Some would jump straight into a solution, but to me taking a step back and visualizing the problem is very essential in determining the right solution. Well done!

 

Thank you for your kind words. And you're right, I totally don't need to reassign the value to ar. Thanks for pointing it out :)

Code of Conduct Report abuse