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

112
Vistas
Addition assignment null issue

Hi I'm getting an issue where the Addition assignment += is returning a null value and I'm not sure why this is. Here is an example of this circled in green:

enter image description here

Here is the code I'm working with:

    for (let i = 0; i < res.rowCount; i++) {
        let username = res.rows[i].user_id
        let level = res.rows[i].lvl
        let xp = res.rows[i].xp
        embed.description += `# ${i+1}. **${username}** **Level: ${level}** | **XP: ${xp}**\n`;}
        message.reply({ embeds: [embed]});
            
    

}

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

0

It sounds like embed.description has a null initial value, and concatenating to that will first "stringify" that value. Observe:

var foo = null;
foo += "test";
console.log(foo);

You can conditionally set embed.description before updating it, so if it's null make it an empty string:

embed.description = embed.description ?? '';

For example:

var foo = null;
foo = foo ?? '';
foo += "test";
console.log(foo);

about 4 years ago · Juan Pablo Isaza Denunciar

0

It looks at the first loop iteration, embed.description is null, you concatenated null with a string which gives "null<string>".

var a = null;
a += "string";
console.log(a);

try setting blank/empty string to embed.description before for loop, like

embed.description = "";
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