Skip to content

Instantly share code, notes, and snippets.

@GAierken
Created November 13, 2020 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GAierken/851844056ae45cbb1d3da04732f72fac to your computer and use it in GitHub Desktop.
Save GAierken/851844056ae45cbb1d3da04732f72fac to your computer and use it in GitHub Desktop.
const sortedSquares = (A) => {
return A.map((ele) => { // transform the given array
return ele*ele //square the element
}).sort((a,b) => {
return a-b // sort by ascending order
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment