Thank you Khushbu for going through the challenges and providing improved solutions.
For challenge 13, as you noted, I slightly modified the original challenge as I thought it would be neater if all truthy values come first. I'll add your solution as an alternative.
For challenge 15, your solution is indeed much more performant. My goal was to use declarative array methods as much as possible. I'll include your solution as a faster alternative.
Hi Khushubu thank you for your comment. I just have a quick question. I see that you use the spread operator "..." a lot. Is there a reason as to why you need to use it? I'm curious. under what circumstances do you need to use it?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For Challenge 13, as given in the original question, if we were to maintain order,
Your solution will log :
['sunny', 'seinfeld', 'curb', 'rickandmorty', 'friends']
But the expected output is
['seinfeld', 'sunny', 'curb', 'rickandmorty', 'friends']
So to maintain the order following solution might work,
For challenge 15, it's good that you have shown more use-case of the reduce method.
But it is not an optimal solution as using 2 loops make the time complexity O(N*N).
This problem can be done using a single loop too i.e. O(N).
Finding in an object is much efficient than finding it in an array.
Thank you Khushbu for going through the challenges and providing improved solutions.
For challenge 13, as you noted, I slightly modified the original challenge as I thought it would be neater if all truthy values come first. I'll add your solution as an alternative.
For challenge 15, your solution is indeed much more performant. My goal was to use declarative array methods as much as possible. I'll include your solution as a faster alternative.
Thanks again for the feedback! 😁
Hi Khushubu thank you for your comment. I just have a quick question. I see that you use the spread operator "..." a lot. Is there a reason as to why you need to use it? I'm curious. under what circumstances do you need to use it?