var a = number; // тут у нас число var b = secondnumber; // тут у нас второе число var action = '+'; //действие допустим добавление var result = a + action + b; // сделаем пример 1 + 1 console.log(result); //результат выведет нам 1+1, а вместо этого нам нужно 2! How can you implement exactly the mathematical action and not just add the text together? The topic seems to be simple, but I cannot understand what the matter is, I will be grateful for your help!
evalthat allows to execute arbitrary code. Without its use, just like in any other language: using the parsing of the expression, or as in the answer below, check the sign immediately and perform the corresponding function - Grundy