Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 24, 2019 04:22
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 codecademydev/fdb8127c1c89a4b3b959be1ab533c9d6 to your computer and use it in GitHub Desktop.
Save codecademydev/fdb8127c1c89a4b3b959be1ab533c9d6 to your computer and use it in GitHub Desktop.
Codecademy export
// 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