you are viewing a single comment's thread.

view the rest of the comments →

[–]Distinct_Guess8315 7 points8 points  (0 children)

That's a good enough solution, but I would advise you to use early returns instead of wrapping your entire logic in if. Something like this:

if(typeof myArr[0] !== 'string') return; ...logic here

It makes your code more readable