Skip to content

Commit

Permalink
✨ Implement squared sorted array
Browse files Browse the repository at this point in the history
  • Loading branch information
matssom committed Jun 19, 2021
1 parent bf2b577 commit 2d208c2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/easy/sorted_squared_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Square a sorted array and return it still sorted

function sortedSquaredArray(array) {
for (let i = 0; i < array.length; i++) {
array[i] = array[i] * array[i]
}
return array.sort((a, b) => a - b)
}

0 comments on commit 2d208c2

Please sign in to comment.