String type as an array type conversion cycle output

// method:
// function: to help me do something?
// Memory: What incoming yes. What return;

STR = var "1-1-1";
// Function: an array of delimited string;
// passed: string (delimiters, the corresponding upper and lower)
// Returns: an array (each member is a string)
var ARR = str.split ( "-");

// three members: 2 0. 1;
// the console.log (ARR);

SUM = 0 var;
// sum: summing the array, so that each member with variable applied above;
for (var I = 0; I <arr.length; I ++) {
// get the array index , to get the array member;
// the console.log (ARR [I]);

// 转化数据类型
// arr[i]
arr[i] = arr[i] * 1;

sum += arr[i];

}

// loop above, if all the execution is completed, then i == arr.length

alert(sum);1

Published 68 original articles · won praise 0 · Views 1294

Guess you like

Origin blog.csdn.net/zmmsdk/article/details/102583940