Mushi

ex1 js

Sep 24th, 2020
893
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log(checkCash([
  2.     {name: 'Amy', cash: 20},
  3.     { name: 'Diego', cash: 100},
  4.     { name: 'Igor', cash: 1}
  5. ]) === false)
  6.  
  7. console.log(checkCash([
  8.     {name: 'Alice', cash: 240},
  9.     { name: 'Hugo', cash: 100},
  10.     { name: 'Carter', cash: 30}
  11. ]) === true)
  12.  
  13. console.log(checkCash([
  14.     {name: 'Alice', cash: 240},
  15.     { name: 'Hugo', cash: 100},
  16.     { name: 'Carter', cash: 30}
  17. ]) === true)
  18.  
  19. console.log(checkCash([
  20.     { name: 'Adalberto', cash: 25},
  21.     { name: 'Olga', cash: 0},
  22.     { name: 'Helen', cash: 4}
  23. ]) === false)
  24.  
  25. console.log(checkCash([
  26.     { name: 'Adalberto', cash: 25},
  27.     { name: 'Olga', cash: 0},
  28.     { name: 'Helen', cash: 4}
  29. ]) === false)
  30.  
  31. function checkCash(friends) {
  32.     let cond = true
  33.     friends.forEach(element => {
  34.         //console.log(element.cash)
  35.         if (element.cash < 10) {
  36.             //console.log("entered here")
  37.             cond = false
  38.             //return false
  39.         }
  40.     })
  41.     //console.log("a")
  42.     return cond
  43. }
  44.  
RAW Paste Data