Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- две решения със .sort и със loop дават 100/100:
- function sortNums(a, b, c){
- let array = [a, b, c];
- array.sort((x, y) => y-x);
- for(let i = 0; i < array.length; i++){
- console.log(array[i]);
- }
- }
- sortNums(2, 1, 3);
- function sortNums(a, b, c) {
- if (a >= b && a >= c) {
- console.log(a);
- if (b >= c) {
- console.log(b);
- console.log(c);
- } else {
- console.log(c);
- console.log(b);
- }
- } else if (b >= a && b >= c) {
- console.log(b);
- if (a >= c) {
- console.log(a);
- console.log(c);
- } else {
- console.log(c);
- console.log(a);
- }
- } else {
- console.log(c);
- if (a >= b) {
- console.log(a);
- console.log(b);
- } else {
- console.log(b);
- console.log(a);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement