Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda