我想知道为什么这个脚本的答案是
var h1Array = $('h1').first().text().split(' '),
h1Last = h1Array[h1Array.length-1],
answerElem = $('#jschl_answer');
answerElem.val(22+14*10);
answerElem.val(parseInt(answerElem.val())+(h1Last.substr(0,h1Last.length-1)).length);
这个的总和是多少?我知道10 * 14 = 140 + 22 = 162,但为什么在这种情况下总和为179
所以从那里我们得到额外的17?
另一个例子
var h1Array = $('h1').first().text().split(' '),
h1Last = h1Array[h1Array.length-1],
answerElem = $('#jschl_answer');
answerElem.val(46+36*8);
answerElem.val(parseInt(answerElem.val())+(h1Last.substr(0,h1Last.length-1)).length);
sum = 347而answerElem.val的总和(46 + 36 * 8);实际上等于334所以从那里得到额外的13?
提前谢谢。
答案 0 :(得分:4)
answerElem.val(22+14*10); // 162
answerElem.val(
parseInt(answerElem.val()) + // 162
(h1Last.substr(0,h1Last.length-1)).length // guess this must be 17
);
答案 1 :(得分:0)
这是最后一个令牌的长度,由“”,
标记