TZinovieva

Max Number

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