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

111
Views
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 answers
Answer question

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 Report

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 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!