TZinovieva

Max Number

Jun 9th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function maxNumber(input) {
  2.     index = 0;
  3.     let command = input[index];
  4.     index++;
  5.     let maxNum = Number.MIN_SAFE_INTEGER;
  6.  
  7.     while (command !== "Stop") {
  8.         let currentNum = Number(command);
  9.  
  10.         if (currentNum > maxNum) {
  11.             maxNum = currentNum;
  12.         }
  13.         command = input[index];
  14.         index++;
  15.     }
  16.     console.log(maxNum);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment