Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. //This is what I have tried. The final output result is showing undefined
  2.  
  3.  
  4. const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
  5. const squareList = function(arr) {
  6. "use strict";
  7. const squaredIntegers = function(num) {
  8. (function() {
  9. arr.filter(Number.isInteger(num) && num > 0);
  10. });
  11. return squaredIntegers;
  12. }
  13. }
  14.  
  15. const squaredIntegers = squareList(realNumberArray);
  16. console.log(squaredIntegers);
  17.  
  18. //Here is the Arrow function I was trying to convert
  19.  
  20. const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
  21. const squareList = (arr) => {
  22. "use strict";
  23. const squaredIntegers = arr.filter(num => Number.isInteger(num) && num > 0);
  24. return squaredIntegers;
  25. };
  26. const squaredIntegers = squareList(realNumberArray);
  27. console.log(squaredIntegers);
  28.  
  29.  
  30. //The code should output this
  31. [4, 42, 6];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement