Skip to main content
added 1 character in body
Source Link
Mamun
  • 69k
  • 9
  • 51
  • 62

The initial value of totalSum is string. Thus += is doing the string concatenation. To perform the arithmetic operation, change the initial value to number (0).

Change

var totalSum = '0'; 

To

var totalSum = 0; 

The initial value of totalSum is string. Thus += is doing the string concatenation. To perform the arithmetic operation change the initial value to number (0).

Change

var totalSum = '0'; 

To

var totalSum = 0; 

The initial value of totalSum is string. Thus += is doing the string concatenation. To perform the arithmetic operation, change the initial value to number (0).

Change

var totalSum = '0'; 

To

var totalSum = 0; 
Source Link
Mamun
  • 69k
  • 9
  • 51
  • 62

The initial value of totalSum is string. Thus += is doing the string concatenation. To perform the arithmetic operation change the initial value to number (0).

Change

var totalSum = '0'; 

To

var totalSum = 0;