猿问

求大神解析其中的意思?

for( var i =0;i<arr.length;i++ ){
   var index = arr[i].indexOf(':');
   
sum += parseInt(  arr[i].substr(index+1,2)  );  
}


qq_慕莱坞8430671
浏览 1440回答 3
3回答

慢l慢

第一句,循环的条件;第二句,把“:”首次出现的位置赋值给index;第三句,同sum =sum+parseInt(  arr[i].substr(index+1,2)  ),其中arr[i].substr(index+1,2) 把字符串中“:”出现之后两个字符取出来,parseInt(  arr[i].substr(index+1,2)  )把取出来的两个字符转换成数字类型以用于计算。

慕的地8582982

OKFCMUUFSDNFVYYPMWRRCFUHTRLUSNUWDOKPPCNEXOATDQRBUBRQXWWROAJWHQZLWJCMPAWQGWPGWOLRGGQGGCSJWIVKVPCMPDDELNHEIZDFMMPSRKXKATALLTPSLZYYZBXRUXEOFFRSJJNSBNXABZQJWPBNQDKCFCZURUEBYVPSJNSPJMMMZCVCVDJWFBFFGJZMYFRDDMJDGEPARTBVUUELRRDKAPDADUNEUESZPGJTZMMWSTKZMICPERSPMGNGWQCPQQCKYATGEHNNETHNFNANANKHBYCVIYOFVSOOZORBRZILCZJWIEEOVLEQBDWKQSFFFMJXSVKQTQJATWTESXWQZQRDQXKRAZAAONXKYLLDTTMMSANHRELRRBYBIZPPNCYVPFQYYUWDTHXAMWPMDWGHORHHBBBBIIFBMMVGHHKAEAWINRAEYPJTGPFVYVLYXLJXGMMPFEPWZTVHENHMSFFAGNMJCKNTNUTGBEPTZEFZWUBKXLIVVYCWYIYBPJTXOVGJKHKDWTTDNNTJUXDQGQWMTFUGDDGFPCBVPKFEBLLLWQAQXPWKNDDTROJKUXXUTADQHSIERDHRKBMLLRFREHEBAVLCMIVHVRRHXXGKSUDEIZVSLQTFOJMUXNQQEUGWSWZPRVCTPIEIDMKNQWBLSIDFAKULDHXKKAXMISVHKBZDSPXNDAAIYHRFJYPGWCADOEGPMJGWWOMTZJMIENQWRNOQGPYUXAZXISJYILUKBUSCLOKUDGJYLOKYUQSBYHKWUXURUWMVGCPGOBLADGJZICHRRTUJNKZCCQTGJLOKURNGSWUXZPDHXGNCMADGQLISCCTYXAWTISTJWLPSHRAQHRHTAXLNCMCSNRDGQMTQSHRBSZRO
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答