Bloody hell. I do not understand, Is that I am so stupid, or the learning material is not good, which does not learn??? Every single task is unbelievable, I can not understand… I have no idea how to do it…How is it possible to learn this way, no knowledge, but do the task!!! It looks like I must have previous coding experience to study here…I never felt so stupid in 40 years…
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
I just solved it and to be honest, I’m not sure if I cheated a little by calling another function to help. I’m not sure if the original intention was to have the entire logic integrated in 1 function - which somehow my brain was unable to refactor. Anyway, what I came in to say is to just keep going, it’ll eventually work out.
If you are still stuck, please consider creating an array of all natural numbers, then use a for… of… loop to filter those that match the condition to find primes.
You need a (helper) function to check if a number is prime. Work on that first and foremost.
Once you can determine a number is prime, you will have to use that helper function on a set of numbers. You can wrap a for loop around this to go over each item in the set, but you can also use higher order functions for this part, and your results will need to be saved to an array.
For the easiest part, just add all those prime numbers you’ve gotten in a new array together.