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

196
Views
var return to NaN instead of number

Hey so i've something like that

var zxc1 = 1846;
var zxc2 = 1649;
var zxc3 = 174;
var zxc4 = 27;

if(message.toLowerCase() == ('!asd')) { client.say(channel, `zxc1`  +`(${+ zxc1.toLocaleString()})` +` | zxc2 `+`(${+ zxc2.toLocaleString()})` +` | zxc3 ` +`(${+ zxc3.toLocaleString()})` +` | zxc4 ` +`(${+ zxc4.toLocaleString()})` +` | :) `);}

After typing !asd:

Result : zxc1(NaN) | zxc2 (NaN) | zxc3 (174) | zxc4 (27) | 2

what's the problem?

Why is zxc3 and zxc4 working but zxc1 and zxc2 no

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In ${+ zxc1.toLocaleString()} the + will be applying on the result of zxc1.toLocaleString() to coerce it back to a number (which seems counterproductive).

If you are not sure if something is a number I do recommend you use the number function e.g. ${Number(zxc1).toLocaleString()} rather than using +

The reason why 3 and 4 are working is because (most likely) your locale adds a thousands separator and so 1 and 2 are not castable back to numbers directly

about 4 years ago · Juan Pablo Isaza Report
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!