Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function minNumber(input) {
- let index = 0;
- let min = Number.MAX_VALUE;
- while (input[index] !== "Stop"){
- let num = Number(input[index]);
- if (min > num){
- min = num;
- }
- index++;
- }
- console.log(min);
- }
- Решение с фор цикъл:
- function minNumber(input) {
- let min = Number.MAX_VALUE;
- for(let i = 0; i <= Number.MAX_VALUE; i++) {
- if (input[i] === "Stop"){
- break;
- } else if (min > Number(input[i])) {
- min = Number(input[i]);
- }
- }
- console.log(min);
- }
- Фундаменталс решение:
- function maxNumber(input) {
- console.log(Math.min(...input.slice(0, -1).map(Number)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement