Ad
Mathematics
Algorithms
Logic
Numbers

Create a function to be able to add, substract, multiply or divide all the numbers given in the array provided.

Parameters:

1. Array
2. Operator:
    -'Add'
    -'Substract'
    -'Divide'
    -'Multiply'

Example:

function: getResult(array, operator)
array: [4, 2, 1]

operator: 'Add'
result: 7

operator: 'Substract'
result: 1

operator: 'Divide'
result: 2

operator: 'Multiply'
result: 8

function getResult(array, operator) {
    //Good luck!
}