Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write an if-statement that takes two double variables a and b and exchanges their values if the first one is greater than the second one.
- // As a result print the values a and b, separated by a space.
- // Examples:
- // a b result
- // 5 2 2 5
- // 3 4 3 4
- // 5.5 4.5 4.5 5.5
- let input = ['5.5', '4.5'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- // get two values a and b
- let a = +gets();
- let b = +gets();
- //exchanges their values if the first one is greater than the second one and
- //print separated by a space
- if (a > b) {
- console.log(`${b} ${a}`);
- } else {
- console.log(`${a} ${b}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement