Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Hardcoding array.length of 16 is far from optimal. Commented Jul 26, 2015 at 22:27
  • I'm torn. On one hand, I think that people take answer on SO and adapt them to best practices that they know or use - and understand that answers on SO are oftentimes like they are for brevity than anything else. On the other hand... CTRL-C, CTRL-V, done! cringe Commented Jul 26, 2015 at 22:38
  • Thanks for responses, but I'm getting undefined returned. Commented Jul 26, 2015 at 22:45
  • georgeb1, please notice that I used array[i] in the for loop, but you actually don't have a variable called 'array'- at least in the part you shared. Please share your JS code and the error you get. You can't get useful feedback without showing your code and the error messages explicitly. Commented Jul 26, 2015 at 22:52
  • Yes, I understand that @melis. I substituted the correct array that returns current output above. Commented Jul 26, 2015 at 23:01