Update calculator.js
This commit is contained in:
parent
888383a44e
commit
e64d488a26
calculator
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue