Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- РЕШЕНИЕ С WHILE:
- function maxNumber(input) {
- let index = 0;
- let max = Number.MIN_SAFE_INTEGER;
- let command = input[index];
- while (command !== "Stop") {
- let num = Number(command);
- if (max < num) {
- max = num;
- }
- index++;
- command = input[index];
- }
- console.log(max);
- }
- РЕШЕНИЕ С FOR:
- function maxNumber(input) {
- let max = Number.MIN_SAFE_INTEGER;
- let command = input[0];
- for (let i = 1; command !== "Stop"; i++) {
- let num = Number(command);
- if (max < num) {
- max = num;
- }
- command = input[i];
- }
- console.log(max);
- }
- ИЛИ ЛЕКО ТАРИКАТСКAТA:)
- function maxNumber(input) {
- let max = Number.MIN_SAFE_INTEGER;
- for (let i = 0; input[i] !== "Stop"; i++) {
- if (max < Number(input[i])) {
- max = Number(input[i]);
- }
- }
- console.log(max);
- }
- ФУНДАМЕНТАЛС РЕШЕНИЕ:
- function maxNumber(input) {
- console.log(Math.max(...input.slice(0, -1).map(Number)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement