How to sort an array of integers correctly

By default, the sort method sorts elements alphabetically. To sort numerically just add a new method which handles numeric sorts (sortNumber, shown below) – Documentation: Mozilla Array.prototype.sort() recommends this compare function for arrays that don’t contain Infinity or NaN. (Because Infinity – Infinity is NaN, not 0). Also examples of sorting objects by key.

Syntax error: Illegal return statement in JavaScript

return only makes sense inside a function. There is no function in your code. Also, your code is worthy if the Department of Redundancy Department. Assuming you move it to a proper function, this would be better: EDIT much much later: Changed code to use json_encode to ensure the message contents don’t break just because of an apostrophe … Read more

JavaScript array to CSV

The cited answer was wrong. You had to change to As to why the cited answer was wrong (funny it has been accepted!): index, the second parameter of the forEach callback function, is the index in the looped-upon array, and it makes no sense to compare this to the size of infoArray, which is an … Read more

“Uncaught TypeError: a.indexOf is not a function” error when opening new foundation project

I’ve created a new Foundation 5 project through bash, with foundation new my-project. When I open the index.html file in Chrome an Uncaught TypeError: a.indexOf is not a function error is shown in the console, originating in jquery.min.js:4. I created the project following the steps on the foundation site, but I can’t seem to get … Read more