Code Snippets
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Welcome to the Collection of Javascript Code Snippets
Prime Numbers OR Not
1
2
3
4
5
6
7
8
9
10
11
function fnc(n) {
for (let i = 2; i < n; i++) {
if (n % i === 0) return false;
}
return true;
}
console.log(fnc(7));
console.log(fnc(9));
console.log(fnc(23));
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content