Thank You! Glad to see in codewars someone concerns about efficiency.
It is even possible to determine the day of the week for 1 January without new Date().
P.S. Sometimes I do much stranger things...
Doing this math in milliseconds is a super bad idea, and completely unnecessary.
You could have used lodash's range() method generate the months array and turn this into a one liner.
Pretty efficient except for one line:
This would be more efficient as:
new Date(year, 0)
Mixing let and var is not "best practice".
Woops, sloppy! Thanks :)
I just learned the join method, so I decidied it would be cool to use it in this problem. Thank you for your help :]
Split/Join is significantly less efficient than replace.
Always use curly braces on if statements for readability and maintainability.
toCharArray() creates a copy of the string. You should always avoid this method.
Do not use toCharArray(), it causes the string to be copied, where a copy is not necessary.
n >= arr.length
Doesn't work for all test cases.
Needs a test case where some words are a substring of previous words.
Example: "starborn star"