Update calculator.js

This commit is contained in:
Mayar-Hassanin98 2020-07-25 16:49:19 +02:00 committed by GitHub
parent 888383a44e
commit e64d488a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 17 deletions
calculator

View File

@ -1,25 +1,33 @@
function add () {
function add (a,b) {
return a+b;
}
function subtract (a,b) {
return a-b;
}
function sum (array) {
return array.reduce(total,current )=> total+=current,0);
}
function subtract () {
function multiply (a,b) {
return array.length? array.reduce(accumaltor,nextitem )=> accumaltor*nextitem):0;
}
function power(a,b) {
return Math.pow(a,b)
}
function sum () {
}
function multiply () {
}
function power() {
}
function factorial() {
function factorial(a) {
if(a==o)return;
let fact=1;
for(let i=n ;i<0 ;i--)
{
fact*=1;
}
return fact;
}
module.exports = {
@ -29,4 +37,4 @@ module.exports = {
multiply,
power,
factorial
}
}