DEV Community

Discussion on: What The For Loop?

Collapse
 
ytjchan profile image
ytjchan

While loop saves the day!

Collapse
 
_gdelgado profile image
Gio

Or better yet ... use some functional programming!

Array(20)
  .fill()
  .map((_, i) => i + 1)
  .filter((num) => num % 2 !== 0)
  .join('\n')