Advertisement
Guest User

Sort Three Numbers_Conditional Statements

a guest
May 1st, 2019
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. const getGets = (arr) => {
  2. let index = 0;
  3.  
  4. return () => {
  5. const toReturn = arr[index];
  6. index += 1;
  7. return toReturn;
  8. };
  9. };
  10. // this is the test
  11.  
  12. const test = [
  13. -5,
  14. 3,
  15. -5,
  16. ];
  17.  
  18. const gets = this.gets || getGets(test);
  19. const print = this.print || console.log;
  20.  
  21. let x = +gets();
  22. let y = +gets();
  23. let z = +gets();
  24.  
  25. let maxNum = 0;
  26. let midNum = 0;
  27. let minNum = 0;
  28.  
  29. if(x > y && x> z)
  30. {
  31. maxNum= x;
  32.  
  33. if(y>z)
  34. {
  35. midNum= y;
  36. minNum = z;
  37. }
  38. else if(y<z)
  39. {
  40. midNum = z;
  41. minNum = y;
  42. }
  43. }
  44. if(y > x && y>z)
  45. {
  46. maxNum= y;
  47. if(x>z)
  48. {
  49. midNum=x;
  50. minNum=z;
  51. }
  52. else if(x<z)
  53. {
  54. midNum=z;
  55. minNum=x;
  56. }
  57. }
  58. if(z>y && z>x)
  59. {
  60. maxNum=z;
  61. if(y>x)
  62. {
  63. midNum=y;
  64. minNum=x;
  65. }
  66. else if(y<x)
  67. {
  68. midNum=x;
  69. minNum=y;
  70. }
  71. }
  72. print(maxNum, midNum, minNum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement