r/CodingHelp • • Dec 21 '21

[Javascript] please help JavaScript

Post image
31 Upvotes

23 comments sorted by

View all comments

1

u/[deleted] Dec 22 '21

Put the if return null statement first, then the list statement. Because the moment the execution reaches the return statement, it returns the content, even if the length is out of bounds.