Advertisement
darkmavis1980

Untitled

Feb 16th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // return early strategy
  2. let fun1 = function(a, b){
  3.     if(a > b) {
  4.         return true;
  5.     }
  6.     if(b > a) {
  7.         return false;
  8.     }
  9. }
  10.  
  11. let fun2 = function(a, b){
  12.     let result;
  13.     if(a > b) {
  14.         result = true;
  15.     }
  16.     if(b > a) {
  17.         result = false;
  18.     }
  19.     return result;
  20. }
  21.  
  22. let res1 = fun1(1,2);
  23. let res2 = fun2(1,2);
  24. console.log(res1, res2); //false, false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement