completed Calculator exercise

This commit is contained in:
Don 2022-07-26 15:59:26 -04:00
parent 9577d2bd5d
commit 707a589009
1 changed files with 18 additions and 11 deletions

View File

@ -1,25 +1,32 @@
const add = function() {
const add = function(firstVariable, secondVariable) {
return firstVariable + secondVariable;
};
const subtract = function(firstVariable, secondVariable) {
return firstVariable - secondVariable;
};
const sum = function(myArray) {
return myArray.reduce((runningTotal, myVariable) => runningTotal + myVariable, 0);
};
const multiply = function(myArray) {
return myArray.reduce((runningTotal, myVariable) => runningTotal * myVariable, 1);
};
const subtract = function() {
const power = function(baseNum, power) {
return baseNum ** power;
};
const sum = function() {
};
const multiply = function() {
};
const power = function() {
};
const factorial = function() {
const factorial = function(myVariable) {
if (myVariable < 0) {
return -1;
} else if (myVariable === 0) {
return 1;
} else {
return (myVariable * factorial(myVariable - 1))
}
};
// Do not edit below this line