Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a program that finds the biggest of three numbers.
- // Examples:
- // a b c biggest
- // 5 2 2 5
- // -2 -2 1 1
- // -2 4 3 4
- // 0 -2.5 5 5
- // -0.1 -0.5 -1.1 -0.1
- let input = ['-0.1', '-0.5', '-1.1'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- // Get the numbers
- let a = Number(gets());
- let b = Number(gets());
- let c = Number(gets());
- // Find the biggest number with conditional statement
- if (a > b && a > c) {
- console.log(a)
- } else if (b > a && b > c) {
- console.log(b)
- } else if (c > a && c > b) {
- console.log(c)
- }
- //Second option with The Math.max() function
- let biggestNum = Math.max(a, b, c);
- console.log(biggestNum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement