If you're looking to add up all the values in an array using JavaScript, the addAll function is definitely worth knowing about. This function adds up all the elements of an array and returns the total sum.

### Method 1: Traditional For Loop

The first method that comes to mind when adding up all the values in an array is using a traditional for loop. Here's an example:


var total = 0;
for (var i = 0; i < arr.length; i++) {
total += arr[i];
}
}

var myArray = [1, 2, 3, 4, 5];


As you can see, we first declare a variable called "total" with an initial value of zero. We then loop through each element in the array using a for loop and add the value of each element to our "total" variable. Finally, we return the total sum.

### Method 2: Array.reduce()

Another method that can be used to add up all the values in an array is by using the built-in JavaScript function called reduce(). Here's an example:


var total = arr.reduce(function(sum, value) {
return sum + value;
}, 0);
}

var myArray = [1, 2, 3, 4, 5];


In this method, we first declare a variable called "total" and use the reduce() function to add up all the elements in the array. The reduce() function takes two arguments: a callback function and an initial value. The callback function takes two arguments: the accumulator (which is the value returned from the previous iteration) and the current value being iterated over. In each iteration, the callback function returns the sum of the accumulator and the current value. Finally, we return the total sum.

### Method 3: Using a For-Of Loop

A more modern way of looping through an array is by using a for-of loop. Here's an example of how to add up all the values in an array using a for-of loop:


var total = 0;
for (var value of arr) {
total += value;
}
}

var myArray = [1, 2, 3, 4, 5];