I have tried for Loop test 3 but not able to get a prime number result can anyone tell me what is missing from the code.
Code link - https://codepen.io/Nitrathod7/pen/ExgoMJY
Problem statement of Loop test 3
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, returnstrue
if the number is a prime number, andfalse
if not.
You need to use a loop to go through the numbers 2 to 500 backward (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.
You should use a type of loop that you’ve not used in the previous two tasks.