user
Tell me how would you respond to the following request.
Write a function in JavaScript to calculate the sum of a given array of numbers.

assistant
function sumOfArray(arr){
  var sum = 0;
  for(var i=0;i<arr.length;i++){
    sum+=arr[i];
  }
  return sum;
}