JavaScript Challenge - Prime Number Finder

function primeFinder(n) { let result=[]; for(let i=0; i<=n; i++) { let count=0; for(let j=0; j<=i; j++){ if(i%j===0){ count++; } } if(count===2){ result.push(i); } } return result; } console.log(primeFinder(21)) // Leave this so we can test your code: module.exports = primeFinder;
function primeFinder(n) { // Write your code here if (typeof n === 'number') { let primeArray = []; for (let i = 1; i <= n; i++) { let miniArray = []; for (let j = 1; j <= i; j++) { if (i % j === 0 && j != 1) { miniArray.push(j); } } if (miniArray.length === 1) { primeArray.push(miniArray[0]); } } return primeArray; } } console.log(primeFinder(11)) // Leave this so we can test your code: module.exports = primeFinder;