I understand what most of the code in line 5 is doing. The one part I’m not completely clear on is the part in the filter that is
num % parseInt(num) ===0
I’m trying to filter out the decimals. At first I tries using num.isInteger and that didn’t work and I think the reason why is that the return value of that is a “true/false” and not a string or array of the numbers that are integers.
parseInt gives a string of numbers, which is good! So I understand why this should be used.
The “%” confuses me. I looked it up and it’s listed as “Modulus (division remainder)” so what is going on here? Am I dividing all my numbers by themselves and seeing if that gives me 0, and then taking that string further down the chain of functions? I don’t understand how that would get rid of the decimals and pass only whole numbers. Since all numbers divided by themselves are 1 I don’t see how that would pass.
I think I’m fundamentally misunderstanding the use and meaning of “%” here. Could anyone help clarify this?