JS --- reverse traversal achieved Array array, the array is connected string

// =================== 求最大值=====================================
<script>
  var arr = [10,35,765,21345,678,89];
  var max = arr [0];
  for (var i=0;i< arr.length;i++) {
    if (max<arr[i]){
      max = arr [i];
    }
  }
  console.log("最大值:" + max);
</script>
// =================== 求最小值=====================================
<script>
  var arr = [10,35,765,21345,678,89];
  var max = arr [0];
  for (var i=0;i< arr.length;i++) {
    if (max>arr[i]){
      max = arr [i];
    }
  }
  console.log("最小值:" + max);
</script>
// iterate reverse ============================ ================= ==============
<Script>
  var ARR = [1,2,3,4,5,6,7,8,9];
  for (var. 1-I = arr.length ; I> = 0; I -) {
    the console.log (ARR [I]);
  }
</ Script>
// string concatenation array =========== ======= ==== the first method (adding back from the front) =========
<Script>
  var names = [ "Jay", "Jet", "JJ", "Angela", "Hebe" ];
  var STR = "";
    for (var I = 0; I <-of names.length. 1; I ++) {
      STR + = names [I] + "|"
    }
    the console.log (STR + names [of names.length. 1- ]);
</ Script>
// =========== =========== second array string concatenation method (plus forward from the rear) ==== ================
<Script>
  var names = [ "Jay", "Jet","JJ", "Angela", "Hebe"];
  var STR = "";
  for (var i = 1; i< names.length;i++){
    str += "|" + names[i]
  }
  console.log(names[0]+ str);
</script>
 

============== // remove duplicate array 0, the other data in an array ============
<Script>
  var = ARR [10,20,0,12,0,0,124,32];
  var newArr = [];
  for (var I = 0; I <arr.length; I ++) {
    IF (! ARR [I] = 0) {
    newArr [newArr.length] = ARR [I];
    }
  }
  the console.log (newArr);
</ Script>
// inverted array ===================== ---------- position in the array of the data exchange =============
<Script>
  var = array [10,20,30,40,50,60];
  for (var I = 0; I <= be array.length / 2; I ++) {
    var Array TEMP = [I];
    Array [I] = Array [-be array.length. 1-I];
    Array [. 1-be array.length -i] = TEMP;
  }
  the console.log (Array);
</ Script>
// =========== series seeking scores, the total score, average, maximum and minimum ====== // =========

<Script>
  var = proInput the parseInt (prompt ( "Please enter the number of the class count RESEARCH 17"));
  var proScore = [];
  for (var I = 0; I <proInput; I ++) {
    proScore [proScore.length] = parseInt (prompt ( "Please enter" + (i + 1) + " th student grades"));
  }
  the console.log (proScore);
  var SUM = 0;
  var AVER = 0;
  var proScore = max [0] ;
  var proScore = min [0];
  for (var I = 0; I <proScore.length; I ++) {
    SUM = proScore + [I];
    AVER = SUM / proScore.length;
    IF (max <proScore [I]) {
      max = proScore [I];
    }
    IF (min> proScore [I]) {
      min = proScore [I];
    }
  }
  the console.log ( "class total score:" SUM +);
  Console.log ( "average:" + aver);
  console.log ( "maximum value:" + max);
  console.log ( "Min:" + min);
</ Script>

Guess you like

Origin www.cnblogs.com/ZXH-null/p/12111937.html
Recommended