Skip to content

Instantly share code, notes, and snippets.

@iliacodes
Created October 6, 2022 17:14
Show Gist options
  • Save iliacodes/1f8f0c5b6de783e484e426a790e37afa to your computer and use it in GitHub Desktop.
Save iliacodes/1f8f0c5b6de783e484e426a790e37afa to your computer and use it in GitHub Desktop.
Kata 1 - Sum the Largest Numbers Assignment
function sumLargestNumbers(data) {
var a = data[0];
var b = data[0];
for(i = 1; i < data.length; i++) {
if (data[i] > a) {
b = a;
a = data[i];
} else if (data[i] > b) {
b = data[i];
}
}
return a+b;
}
console.log(sumLargestNumbers([1, 10]));
console.log(sumLargestNumbers([1, 2, 3]));
console.log(sumLargestNumbers([10, 4, 34, 6, 92, 2]));
@iliacodes
Copy link
Author

Kata 1 lab for LHL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment