function magnitude(arr) {
    return Math.sqrt(arr.reduce((acc, val) => acc + val * val, 0));
}
Calculates the magnitude of a given array.
@param {number[]} arr The array to calculate the magnitude of.
@returns {number} The magnitude of the array.