Home > Mobile >  An array of word sum, JS code is as follows: what's the problem? How to write???
An array of word sum, JS code is as follows: what's the problem? How to write???

Time:09-26

Console. Group (" Fri Dec 20 2019 14:41:45 GMT + 0800 (China standard time) appservice generated error ")
The console. The error (" file: pages/index/index, js \ n unknown: Unexpected token, expected, \ n | 31} wherefore, 32 | \ \ n n> 33 | for (I=0; I=& lt; LTH. + + I) {\ n | ^ \ n 34 | enclosing setData ({x1: x1 + word2 (I)}) 35 | \ n the if (I & gt; LTH) break; 36 |} \ n ")
The console. GroupEnd ()


The above errors, an array of word sum, JS code is as follows:
for(i=0; I=& lt; LTH. + + I) {
Enclosing setData ({x1: x1 + word2 (I)})
If (I & gt; LTH) break;
}

What's the problem?

CodePudding user response:

LTH is the length of the array, the X1 is the sum of the values,

CodePudding user response:

Globally defined arrays and combined, and then calculate
 
STR: [1, 2, 3],
Num: 0,
For (var I=0; i That. Data. Num +=that. Data. The STR [I];
}
  • Related