Build a Prime Number Checker Module - Build a Prime Number Checker Module

Tell us what’s happening:

I have completed the project(build-a-prime-number-checker). Every time I click Run Tests, the page crashes (Error 4XX - 5XX
Client has disconnected from local server). Please help.

Your code so far

------------index.js ------

function isPrime(n) {
    if (n < 2) return false;
    if (n < 4) return true;
    if (n % 2 === 0 || n % 3 === 0) return false;
    for (let i = 5; i * i <= n; i += 6) {
        if (n % i === 0 || n % (i + 2) === 0) {
            return false;
        }
    }
    return true;
}

module.exports = isPrime;

----package.json----

{
  "name": "build-a-prime-number-checker-module",
  "version": "1.0.0",
  "description": "checks whether the input number is a prime number",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "prime number",
    "prime",
    "number",
    "checker"
  ],
  "author": "Akeem A.",
  "license": "ISC",
  "type": "commonjs"
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Prime Number Checker Module - Build a Prime Number Checker Module

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-prime-number-checker-module/15722224eb735613bc8dd803.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @Akeem,

Your code was too long to be automatically inserted by the help button.

Please update the message, or reply to this one, to include your code, formatted as follows:

There are two ways you can format your code to make it easier to read and test:

  1. After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)

  1. Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.

To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:

Happy coding

is the repo you are using the latest version?

if so, it may be that there is some bug with your code that is causing everything to crash, please share your code

I’ve updated my question. I’m still getting the same error for that assignment.

you need to do this in a slightly different way, you need to export an object

I am having the same issue. The test crashes after i create a valid package.json. In Codespaces and local dev container …

please create a topic where you post your own code