Advertisement
dhshin

practice_16

Jun 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let arr = [0, 1, 2];
  2.  
  3. let even = arr.map(function(x) { return 2 * x; });
  4. let odd = arr.map(function(x) { return 2 * x + 1; });
  5.  
  6. console.log(even);
  7. console.log(odd);
  8.  
  9. let small = even.concat(odd).filter(function(x) {
  10.     return x < 3;
  11. });
  12.  
  13. console.log(small);
  14.  
  15. small.filter(function(x) {return x === 0; });
  16. console.log(small);
  17.  
  18. small.forEach(function(x, i){
  19.     console.log('arr[' + i + ']=' + x);
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement