Advertisement
Didart

Max Number

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