Answer the question
In order to leave comments, you need to log in
Why does the method return NaN?
In general, there is a method that accepts a string-numbers with an arithmetic operation, which in fact should return the result, those are converted and how to convert normally, and return the result of addition, for example?
function Calculator() {
this.calculate = function (str){
return +str;
}
}
var calc = new Calculator();
console.log(calc.calculate("2 + 4")); // 6
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question