Skip to content

Instantly share code, notes, and snippets.

@thedom85
Created June 23, 2022 09:17
Show Gist options
  • Save thedom85/9fcb3dfff4ebfce6da0ed58eac486a89 to your computer and use it in GitHub Desktop.
Save thedom85/9fcb3dfff4ebfce6da0ed58eac486a89 to your computer and use it in GitHub Desktop.
// https://www.codewars.com/kata/577a98a6ae28071780000989/train/javascript
var min = function(list){
return list.reduce(function (p, v) {
return ( p < v ? p : v );
});
}
var max = function(list){
return list.reduce(function (p, v) {
return ( p > v ? p : v );
});
}
console.log(min([-52, 56, 30, 29, -54, 0, -110]), -110);
console.log(min([42, 54, 65, 87, 0]), 0);
console.log(max([4,6,2,1,9,63,-134,566]), 566);
console.log(max([5]), 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment