Advertisement
Guest User

Untitled

a guest
Sep 24th, 2022
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let minimum = Number.MAX_VALUE //using type Max value as initial for minimum
  3.     let currItem = input.shift(); //taking first value of the input to start processing
  4.  
  5.     while (currItem != "Stop") { //while cycle, running untill Stop is not received
  6.         currItem = Number(currItem); //Parsing to Number, after checking the element is not equal to Stop
  7.         if (minimum > currItem) { // checking if current element is lower than the minimum
  8.             minimum = currItem; //changing the minimum variable value to the recently found newer minimum value
  9.         }
  10.         currItem = input.shift(); //taking next element for processing
  11.     }
  12.  
  13.     console.log(minimum)
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement