To find the average of all elements in an array in Swift, you can use the reduce
function to sum up all the elements in the array and then divide by the number of elements in the array. Here's the code to do that:
main.swift237 chars8 lines
The output of this code will be:
main.swift20 chars2 lines
gistlibby LogSnag