Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Same code gives different result in Codepen and dev tools console
function func(n1) { 
  const foo = n2 => func(n1 + n2)
  foo.toString = () => n1
  return foo;
}

const fo = func(3)
console.log(fo(10))

This is my solution for a Codewars kata. Codewars wanted me to return a number and it actually returns a number in Codewars and Codepen also. But when I paste it to the browser console I get the foo function, not a number.

Why does this happen? What's the difference between Copeden console and browser console? And how do I return a number in browser console?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!