<<<<<<< HEAD Code Wars - Brett Crafton

Find Maximum and Minimum Values of a List

Question

Your task is to make two functions (max and min, or maximum and minimum, etc., depending on the language) that receive a list of integers as input and return, respectively, the largest and lowest number in that list. Examples (Input -> Output)

* [4,6,2,1,9,63,-134,566] -> max = 566, min = -134 * [-52, 56, 30, 29, -54, 0, -110] -> min = -110, max = 56 * [42, 54, 65, 87, 0] -> min = 0, max = 87 * [5] -> min = 5, max = 5

Solution by -

My Solution


	var min = function(list){
		let sortedList = list.sort((a,b) => a - b)
		return sortedList[0];
	}
	
	var max = function(list){
		let sortedList = list.sort((a,b) => b - a)
		return sortedList[0];
	}
				

Try it yourself - CodeWars

======= Code Wars - Brett Crafton

Find Maximum and Minimum Values of a List

Question

Your task is to make two functions (max and min, or maximum and minimum, etc., depending on the language) that receive a list of integers as input and return, respectively, the largest and lowest number in that list. Examples (Input -> Output)

* [4,6,2,1,9,63,-134,566] -> max = 566, min = -134 * [-52, 56, 30, 29, -54, 0, -110] -> min = -110, max = 56 * [42, 54, 65, 87, 0] -> min = 0, max = 87 * [5] -> min = 5, max = 5

Solution by -

My Solution


	var min = function(list){
		let sortedList = list.sort((a,b) => a - b)
		return sortedList[0];
	}
	
	var max = function(list){
		let sortedList = list.sort((a,b) => b - a)
		return sortedList[0];
	}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39