SHARE
TWEET

Filter Implementation

t_sh0w Feb 16th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let numbers = [15, 21, 30, 4, 5, 6, 7, 8];
  2.  
  3. function filterToOddNumbers(arr) {
  4.   let modifiedArr = [];
  5.  
  6.   for (let i = 0; i < arr.length; i++) {
  7.     let currentElement = arr[i];
  8.     if (currentElement % 2 !== 0) {
  9.       modifiedArr[modifiedArr.length] = currentElement;
  10.     }
  11.   }
  12.   return modifiedArr;
  13. }
  14.  
  15. let result = filterToOddNumbers(numbers);
  16. console.log(result);
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