πŸ”₯ Challenge for JavaScript Ninjas:

Mahendra shahiMahendra shahi
2 min read

Can you solve this?
➀ Write a function that returns true if a number is almost prime β€” i.e., has exactly two distinct prime factors.

βœ… Try it out now β†’ https://javascriptninjas.com/?page=6&order_by=&sort=&q=hard


πŸ”Ή 2. Interactive Style (for dev.to, Hashnode, blogs)

πŸ’‘ Can You Crack This?
Here’s a brain-tickler for JavaScript learners:

"Write a function that returns true if a number is almost prime β€” meaning it has exactly two distinct prime factors."

For example:

yamlCopyEditInput: 6 β†’ Output: true   // (2 Γ— 3)  
Input: 30 β†’ Output: false  // (2 Γ— 3 Γ— 5) β†’ 3 distinct  
Input: 21 β†’ Output: true   // (3 Γ— 7)

Solve it directly here: πŸ‘‰ https://javascriptninjas.com/?page=6&order_by=&sort=&q=hard


πŸ”Ή 3. Competition Announcement Style (for Facebook/LinkedIn posts)

πŸš€ Think you’re a JavaScript Ninja? Prove it.

This month’s challenge:
🧩 Write a function that returns true if a number is "almost prime" (has exactly 2 distinct prime factors).

πŸ“Œ Example:
6 β†’ true, 21 β†’ true, 30 β†’ false

Try the full challenge here:
πŸ”— https://javascriptninjas.com/?page=6&order_by=&sort=&q=hard

πŸ’° We run monthly competitions β€” winners get prizes & shoutouts!


πŸ”Ή 4. Gamified Format (for forums or gamified learning platforms)

πŸ•ΉοΈ Mini-Boss Level: Almost Prime Check
Mission: Write a function to check if a number has exactly two distinct prime factors.

Input β†’ 6, Output β†’ true
Input β†’ 30, Output β†’ false
Input β†’ 21, Output β†’ true

🎯 Take the challenge here: https://javascriptninjas.com/?page=6&order_by=&sort=&q=hard


πŸ”Ή 5. Plain Text for Email or WhatsApp Group

πŸ‘‹ Hey! Quick challenge for JavaScript lovers:

Can you write a function that returns true if a number is "almost prime" (i.e., has exactly two distinct prime factors)?

Try these:

  • solve(6) β†’ true

  • solve(30) β†’ false

  • solve(21) β†’ true

Solve this now & join our monthly contest at:
πŸ‘‰ https://javascriptninjas.com/?page=6&order_by=&sort=&q=hard

0
Subscribe to my newsletter

Read articles from Mahendra shahi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mahendra shahi
Mahendra shahi