I have an array where I am mapping it at some point to calculate the sum and percentages. However, when I tried implementing the logic, I noticed that using '*' directly works fine but using '+' adds the two strings together.
For example:
const a = '100';
const b = '10';
const c = a * b;
const d = a + b;
console.log(d)
When I checked the value of d, it returned '10010' while c gave '1000'. This confusion led me to wonder why this is happening.
But then, trying parseInt(a) + parseInt(b)
worked perfectly with output as 110
.