I think it should be better if you convert the input to uppercase outside the loop and instead of slice why not use trim method? We can also just use replace method instead of loop
going over the "very large array" twice ends up taking twice as long, twice as much memory.
if the array was billions of members long - the 10 lines of code you saved would cost a lost of money.
this code may be impressive to newbies exclusively.
In Javascript, the original number outside the function remains unchanged. This is because numbers are passed by value.
It's not the most optimal though. With larger inputs, the difference will start to become noticeable. You should totally avoid iterating twice.
How did I not think of that?! It's so easy!
OMG!! I'll stop coding for one week ok.... don't ask me why
Brilliant
i basically did the same but long way but i think is not the best with O(2n) why is this top in the first place becuase is short or what ?
i did this kata using js objects, really ashamed of myself
yeah, looks like he's just too lazy to make a new variable
Ah yes. Whenever I can't come up with a one-line solution, there will always be one.
I think it should be better if you convert the input to uppercase outside the loop and instead of slice why not use trim method? We can also just use replace method instead of loop
Do you need to handle errors? Like if the array has no outliers or more than 1? Or the array is smaller than 3?
It works well, but it must be refactored as it's really difficult to follow the logic let alone maintain this solution.
going over the "very large array" twice ends up taking twice as long, twice as much memory.
if the array was billions of members long - the 10 lines of code you saved would cost a lost of money.
this code may be impressive to newbies exclusively.
This comment has been reported as abusive
Loading more items...