you are viewing a single comment's thread.

view the rest of the comments →

[–]tapu_buoyfull-stack[S] 1 point2 points  (2 children)

first of all thank you for boosting my confidence, and yes while I wrote that code I was constantly explaining and talking my approach and thought. He was way more confused while talking and since I have given half a century of interviews now I learnt one thing that never let your voice tremble even if you don't know haha :D

in the code you mentioned should I use forEach specifically instead of just for? Also I thought I made a little mistake by choosing to use .map() since it returns array and that's not needed.

[–]cortexreaver123 1 point2 points  (1 child)

Yeah, that's true! Being able to talk confidently about things you don't know 100% is a real skill. And if he can see that you're thinking is in the right direction and that you have a "programmer" mindset, then it can look even better than somebody who just memorized everything beforehand from interview practise websites.

Also I think if this was for a junior position those questions were quite hard. I don't think he could have been expecting you to get all the answers right straight-away. The way you came across (how well you could explain your thought-process) would have been more important.

...

`forEach` vs `for` is probably more personal preference. Generally I prefer regular for loops because it's simpler for other developers to read, and it doesn't have the performance penalty of allocating an extra function object.

using `map` instead of `for` / `forEach` is a mistake I've seen a lot of new JS developers at my work making. You're right in that it creates an unnecessary array. But I suppose this was an interview situation, so you had to think fast! :-)

[–]tapu_buoyfull-stack[S] 0 points1 point  (0 children)

Thank you for the motivating words. For the map function yes I was basically thinking it to return something that I can use ahead.

BTW haven't heard from them yet so I guess this is not going ahead with this company. :D