diff --git a/calculator/calculator.js b/calculator/calculator.js index 2d904a8..c375891 100644 --- a/calculator/calculator.js +++ b/calculator/calculator.js @@ -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 -} \ No newline at end of file +}