Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
.
if (n >= 1 || typeof n === 'int'){
:Do you really want or (
||
)? Also, there is noint
type in JavaScript.This comment is hidden because it contains spoiler information about the solution
First, if you put ```javascript before and ``` behind your code, it will be formatted like javascript code!
This help analysing what you have coded.
Concerning your problem:
This is said in the kata's description:
So besides the fact that you use
Math.abs()
I see no problem in your functionisPrime()
. Just remove this line of code:To avoid implementing the same piece of code multiple times, I checked wether
start
is smaller thanend
and therefore I declared two more variables. Now you can apply these to your loop like this:At least, I don't quite know why you want to sort your primes. There is no need for this and it's only one more line of code which can cause an error...
Thanks! Glad you enjoyed it
The tests you see are just a small part of the whole thing that you get once you press "submit".
I edited this kata a bit, try it now :)
You should always add the error message if possible. That way, one can tell you whether it's a Codewars error or an error with your solution.
You're returning 'arr' inside the for block. You would have to put the return after the for block to make this work.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution