Didart

Min Number

Apr 9th, 2022
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function minNumber(input) {
  2.  
  3.     let inputElement = input[0];
  4.     let index = 1;
  5.  
  6.     let min = Number.MAX_SAFE_INTEGER;
  7.  
  8.     while (inputElement !== "Stop") {
  9.       let num = Number(inputElement);
  10.  
  11.         if (min > num) {
  12.             min = num;
  13.         }
  14.  
  15.         inputElement = input[index];
  16.         index++;
  17.     }
  18.    
  19.     console.log(min);  
  20. }
  21.  
  22. minNumber(["100", "99", "80", "70", "Stop"])
  23.  
Advertisement
Add Comment
Please, Sign In to add comment