Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. // We'll say that a number is 'teen' if it is in the range 13..19 inclusive.
  2. // Given 2 int values, return true if one or the other is teen, but not both
  3.  
  4.  
  5. var loneTeen1 = function (a, b) {
  6.  
  7. if ((((a >= 13) && (a <= 19)) && !((b >= 13) && (b <= 19))) || (((b >= 13) && (b <= 19)) && !((a >= 13) && (a <= 19)))) {
  8. return true;
  9. } else return false;
  10.  
  11. }
  12.  
  13.  
  14. var loneTeen2 = function (a, b) {
  15.  
  16. var aa = 0;
  17. var bb = 0;
  18.  
  19. if ((a >= 13) && (a <= 19)) {
  20. aa = 1;
  21. }
  22.  
  23. if ((b >= 13) && (b <= 19)) {
  24. bb = 1;
  25. }
  26.  
  27. if (aa + bb === 1) {
  28. return true;
  29. } else if ((aa + bb === 2) || (aa + bb === 0)) {
  30. return false;
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement