Java Reference
In-Depth Information
matcher (although we should probably be checking if it is false because this test will
pass if anything but true is returned).
If you refresh the page, you'll see that our new tests are failing, as shown in Figure 10.5 .
This is to be expected, since we're yet to write any code for them.
Figure 10.5. Failing again
We'd better write the isPrime() function. This will use the factorsOf() function
and check to see if the number of factors in the array returned by the factorsOf() func-
tion is 2 . This is because all prime numbers have precisely two factors. Add the following
code to the bottom of the numberCruncher.js file:
Search WWH ::




Custom Search