Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Problem 6. The Biggest of Five Numbers
- //
- //Write a program that finds the biggest of five numbers. Think about a way to do it more efficient.
- //Examples:
- // a b c d e biggest
- // 5 2 2 4 1 5
- // -2 -22 1 0 0 1
- // -2 4 3 2 0 4
- // 0 -2.5 0 5 5 5
- // -3 -0.5 -1.1 -2 -0.1 -0.1
- let input = ['5', '2', '2','4','1'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- //Get all 5 numbers
- let n1 = Number(gets());
- let n2 = Number(gets());
- let n3 = Number(gets());
- let n4 = Number(gets());
- let n5 = Number(gets());
- //Finds the biggest of five numbers
- let maxNum = Math.max(n1, n2, n3, n4, n5);
- console.log(maxNum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement