+ 1
How do I make functions not require quotations?
function math(sign, ...numbers) { return numbers.reduce((previous, current) => { if(sign == '+') { return previous + current; } else if(sign == '-') { return previous - current; } else if(sign == '*') { return previous * current; } else if(sign == '/') { return previous / current; } else if(sign == '%') { return previous % current; } else if(sign == '^') { return Math.pow(previous,current); } }); } I want to make it so that the user doesn't have to put quotations when using the functions, but I get an error when I try to remove the quotations from the if statement/the functions, what do I do?
1 Answer
+ 4
so you want to call the function like this ?
math(+,[1,2,3,4])
i dont think its possible in node