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

Calculate average

Question

Write a function which calculates the average of the numbers in a given list. Note: Empty arrays should return 0.

No examples

Solution by -

My Solution


	function find_average(array) {

		return array.length != 0 ? array.reduce((a,b) => a + b, 0)/array.length : 0
		}
				

Try it yourself - CodeWars

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

Calculate average

Question

Write a function which calculates the average of the numbers in a given list. Note: Empty arrays should return 0.

No examples

Solution by -

My Solution


	function find_average(array) {

		return array.length != 0 ? array.reduce((a,b) => a + b, 0)/array.length : 0
		}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39