DEV Community

samgotowka
samgotowka

Posted on • Updated on

End of Phase 1 at Flatiron

When I Started learning the basics of JavaScript I thought it was going to be pretty straight forward and not require too much practicing but wow I was wrong. The hardest thing for me to learn by far was array iterations. For example I thought the .filter() method was as simple as someConst.filter(isPrime) and whatever else you wanted filtered, but no its like:
const array= [1,2,3,4,5,6,]
function isPrime(num) {
for (let i = 2;num > i; i++) {
if(num % i === 0){
return false;
}
}
}
console.log(array.filter(isPrime)); // [1,3,5]
when I first saw this I was so lost and didn't really understand what was going on but now after really going back and re-reading the documents from my class and looking things up all over the internet I now know that it is basically creating a new variable then seeing if there is a remainder if there isn't, it does not get logged.

well I guess that's all for my first blog about how I was completely wrong about how much work is needed to truly understand what you are coding and how to make it work the way its intended.

Top comments (0)