-
-
Save codecademydev/fdb8127c1c89a4b3b959be1ab533c9d6 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write your code here: | |
const sortYears = years => { | |
let sorted = years.sort(); | |
newArray = []; | |
for (let i = sorted.length-1; i>=0; i--) { | |
newArray.push(sorted[i]); | |
}; | |
return newArray | |
} | |
// Feel free to uncomment the below code to test your function: | |
const years = [1970, 1999, 1951, 1982, 1963, 2011, 2018, 1922] | |
console.log(sortYears(years)) | |
// Should print [ 2018, 2011, 1999, 1982, 1970, 1963, 1951, 1922 ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment