DEV Community

Cover image for #7DaysJS: Primes Until n
Lautaro Lobo
Lautaro Lobo

Posted on • Originally published at lautarolobo.xyz on

#7DaysJS: Primes Until n

Welcome to day 7 of 7 Days of JavaScript!

Today, on the last day of this challenge, we will tackle a hard one.

Write a function that takes a Natural number n, which returns all the primes from 0 to n and a string at the end with some phrase.

Example:

primesUntil(7)
...
2
3
5
'Why the string?'

Hint: you may want to use a helper function.

Give it time. If you feel frustrated, go take a walk and then sit down to try it again.

And then, read the solution here.

Top comments (0)