Hello,
Thanks for reading me.
I would like an Assessment for the loops 3 skill test.
It looks like my code meet the request of the test but I guess there was an easier way.
The Task was:
In this final task, you are provided with the following:
-
i— starts off with a value of 500; intended to be used as an iterator. -
para— contains a reference to a paragraph, which will be used to report the results. -
isPrime()— a function that, when passed a number, returnstrueif the number is a prime number, andfalseif not.
You need to use a loop to go through the numbers 2 to 500 backwards (1 is not counted as a prime number), and run the provided isPrime() function on them. For each number that isn’t a prime number, continue on to the next loop iteration. For each one that is a prime number, add it to the paragraph’s textContent along with some kind of separator.
And Here is my code:
https://codepen.io/spookykasper/pen/OJzqRGL
To meet the request of the task i create:
const separator = document.createTextNode(*);
and add it separately, but it looks like a cheat to me and I wonder
if this is actually the best practice ?
Many thanks!
Spooky



