0
for (let i = 0; i < arrayfirst.length; i++){
        parseInt(arrayfirst[i]);
        parseInt(arraysecond[i]);
        arrayfirst[i] += arraysecond[i];
      }

I parseInt the arrays but they are still concatenating, I even tried parseInt-ing the entire the equation but it just resulted in my code not working.

  • `parseInt(x)` does not mutate the value of `x`, it only returns a new value. You need to cast it in the assignment expression: `arrayfirst[i] = parseInt(arrayfirst[i]) + parseInt(arraysecond[i])`. – Hao Wu Oct 28 '22 at 06:12
  • `parseInt` *returns the number*. It does not magically change whatever the variable holds to a number. JS does not have the facility to do that anyway, as it's always pass-by-value, not pass-by-reference. So, parse *and work with the result*. – VLAZ Oct 28 '22 at 06:13
  • @HaoWu thanks! literally such a dumb mistake. – girliepopper Oct 28 '22 at 18:32

0 Answers0