SHARE
TWEET

Untitled

a guest Nov 19th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var array1 = [1,3,4,6,7,6];
  2. var array2 = [6,2,7,2,5,6,1,3,7];
  3. var arrayRandom = [];
  4. for (var i = 0; i < 10; i++) {
  5.   appendItem(arrayRandom, randomNumber(0,100));
  6. }
  7.  
  8. findMinVal(array1);
  9. findMinVal(array2);
  10. findMinVal(arrayRandom);
  11.  
  12. function findMinVal(list){
  13.  
  14.   console.log("Original:" + list);
  15.  
  16.   var minVal = 100;
  17.  
  18.   for (var i = 0; i < list.length; i++) {
  19.  
  20.    
  21.     if (list[i] < minVal) {
  22.       minVal = list[i];
  23.     }
  24.   }
  25.  
  26.   console.log("The smallest value in the array is: " + minVal);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top