Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created July 10, 2020 16:37
Show Gist options
  • Select an option

  • Save sandrabosk/44cb777632a8c0490dcafc903f6c3fb1 to your computer and use it in GitHub Desktop.

Select an option

Save sandrabosk/44cb777632a8c0490dcafc903f6c3fb1 to your computer and use it in GitHub Desktop.
const arrOfStrings = ['cat', 'wolf', 'yo', 'animal'];
  • Exercise 1: Using the array (arrOfStrings), sort an array from shortest string to the longest.

  • Exercise 2: Using the same arr (arrOfStrings), sort its elements alphabetically.

  • Exercise 3: Sort the objects in the array by age, in descending order.

const people = [
  { name: 'Candice', age: 25 },
  { name: 'Tammy', age: 30 },
  { name: 'Allen', age: 49 },
  { name: 'Nettie', age: 21 },
  { name: 'Stuart', age: 17 },
  { name: 'Bill', age: 19 }
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment