How do I make functions not require quotations? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

10th Sep 2020, 4:12 PM
Sourav Parik
1 Answer
+ 4
so you want to call the function like this ? math(+,[1,2,3,4]) i dont think its possible in node
10th Sep 2020, 4:20 PM
Rei
Rei - avatar