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

172
Vistas
JS question "i dont know why i am getting a different answer"

let a = 10;

let b = "20";

let c = 80;

console.log(--c + +b + --a * +b++ - +b * a + --a - +true);

**I think I should get 108 then multiple it by -1 then multiple it by 16 which should result in -1728 however I am getting an answer of 97!!!!

how is that possible?

when I broke the problem into 3 pieces (--c + +b + --a)(+b++ - +b)(a + --a - +true) the computer agreed with me that the first part should be 108 then -1.

I need help guys. someone explain it to me, please.

THANKS**

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is because of order/preference of operations. as multiplication has higher preference than addition and subtraction.

just put bracers like below it will give required output (-1728).

console.log((--c + +b + --a) * (+b++ - +b) * (a + --a - +true));
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