• 2022-06-16
    【单选题】var arr = [2, 6, 1, 7, 4];var sum = 0;for (var i = 0; i <; arr.length; i++) {sum += arr[i];}运行上面的代码后,sum里面的值是()。[/i]
    A: 20
    B: 25
    C: 18
    D: 26
  • A

    内容

    • 0

      分析下段代码输出结果是( )[br][/br]var arr = &#91;2,3,4,5,6&#93;;[br][/br]var sum =0;[br][/br]for(var i=1;i &#91; arr.length;i++) {<br&#93;sum +=arr[i] }[br][/br]console.log(sum);[/i] A: 20 B: 18 C: 14 D: 12

    • 1

      分析下段代码输出结果是( )。[br][/br]var arr = &#91;2,3,4,5,6&#93;;[br][/br]var sum =0;[br][/br]for(var i=1;i &#91; arr.length;i++) {<br&#93; sum +=arr[i];[br][/br]}[br][/br]console.log(sum);[/i] A: 20 B: 14 C: 16 D: 18

    • 2

      【单选题】var arr = &#91;2, 0, 6, 1, 77, 0, 52, 0, 25, 7&#93;;var newArr = &#91;&#93;;for (var i = 0; i <; arr.length; i++) {if (arr[i] >;= 10) {newArr&#91;newArr.length&#93; = arr[i];}}console.log(newArr);运行上面的代码,输出结果是()。[/i][/i] A: 2,0,6,1,0,0,25,7 B: 7,25,0,0,1,6,0,2 C: 77,52,25 D: 25,52,77

    • 3

      var arr = &#91;2, 0, 6, 1, 77, 0, 52, 0, 25, 7&#93;;var newArr = &#91;&#93;;var j = 0;for (var i = 0; i <; arr.length; i++) {if (arr[i] >;= 10) {_________________}}console.log(newArr);补充完整代码,运行后newArr数组中存放的是arr数组中所有大于等于10的值。[/i] A: j++;newArr[j] = arr[i]; B: newArr[j] = arr[i];j++; C: arr[i]=newArr[j];j++; D: j++;arr[i]=newArr[j];

    • 4

      var arr = &#91;2, 0, 6, 1, 77, 0, 52, 0, 25, 7&#93;;var newArr = &#91;&#93;;for (var i = 0; i <; arr.length; i++) {if (________) {newArr&#91;newArr.length&#93; = arr[i];}}console.log(newArr);补充完整上面的代码,newArr数组中的数据是arr中不包含 0的数据。[/i]