Answer the question
In order to leave comments, you need to log in
Why doesn't the toString method work when displaying the result?
Why am I getting the result of a function in the console and not a calculation?
function func(n1) {
return function foo(n2) {
foo.valueOf = () => n1 + n2
foo.toString = () => n1 + n2
return func(n1 + n2)
}
}
const fo = func(3)
console.log(fo(10))
Answer the question
In order to leave comments, you need to log in
function func(n1) {
const foo = n2 => func(n1 + n2)
foo.toString = () => n1
return foo;
}
const fo = func(3)
console.log(fo(10))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question