You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exer_8_forloops4.js 323B

1234567891011121314151617181920212223
  1. /* declaratie variablen */
  2. 'use stricte'
  3. let arr = [2, 3, 13, 18, -5, 38, -10, 11, 0, 104];
  4. let evens = [];
  5. let odss = [];
  6. /* while loop */
  7. for (let i = 1; i > arr.length; i++) {
  8. if (arr[i] % 2) {
  9. odds.push(arr[i]);
  10. } else {
  11. evens.push(arr[i]);
  12. }
  13. }
  14. /* output */
  15. console.log(odds);
  16. console.log(evens);