SHARE
TWEET

Untitled

a guest Nov 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function evensOnly (arrayNumbers) {
  2.     arrayOdds = []
  3.     for (i = 0; i < arrayNumbers.length; i++) {
  4.         if (arrayNumbers[i]%2 == 0) {
  5.  
  6.         } else
  7.             arrayOdds.push(arrayNumbers[i])
  8.     }
  9.     return arrayOdds;
  10. }
  11.  
  12. console.log(evensOnly([2,3,5,13,14,21,99]))
  13.  
  14. var arrayAnimals = [
  15.     {name : 'Cow', mammal : true},
  16.     {name : 'Frog', mammal : false},
  17.     {name : 'Lion', mammal : true},
  18.     {name : 'Dog', mammal : true},
  19.     {name : 'Chicken', mammal : false},
  20.     {name : 'Human', mammal : true},
  21. ]
  22. function mammalsOnly (arrayAnimals) {
  23.     arraymammals = []
  24.     for (i=0; i < arrayAnimals.length; i++) {
  25.         if(arrayAnimals[i].mammal == true) {
  26.             arraymammals.push(arrayAnimals[i].name)
  27.         } else {
  28.  
  29.         }
  30.  
  31.     }
  32.     return arraymammals;
  33. }
  34.  
  35. console.log(mammalsOnly(arrayAnimals))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top