Skip to content

Instantly share code, notes, and snippets.

@madeleine68
Created September 4, 2021 05:43
Show Gist options
  • Save madeleine68/06b340662015549f6222f72b9b946315 to your computer and use it in GitHub Desktop.
Save madeleine68/06b340662015549f6222f72b9b946315 to your computer and use it in GitHub Desktop.
let sumLargestNumbers = function(data) {
let sorted = data.sort(function(a,b){
return b - a;
})
return sorted[0] + sorted[1];
};
console.log(sumLargestNumbers([1, 10]));
console.log(sumLargestNumbers([1, 2, 3]));
console.log(sumLargestNumbers([10, 4, 34, 6, 92, 2]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment