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.
This should be at least a 7 kyu. Many other 8 kyu's are really simple oneliners. This kata requires multiple if statements and a formula you need to figure out yourself beforehand.
You don't have to split a string to calculate its length.
You can use j instead of n to add to arr[i - 1] or make j loop between arr[i - 1] and arr[i] and just push j.
This solution only loops over the array once, so it's much faster than using indexOf on every array element.
This comment is hidden because it contains spoiler information about the solution
The 2 examples in the description are wrong. Those values should be in an array as one argument instead of each value as a separate argument.
Apparently, 'this' is an object instead of a string, even though my solution still passed the test in most cases. Use this.split('').join('') to get the string and work with that.
Missing test cases.
I saw someone with a wrong solution: return num % 4 !== 1; This only gets accepted because it works with the 2 given test cases, but if the remainder is greater than 1, it gives the wrong result.
Does not always test with a string with only words that start with uppercase or only words that start with lowercase, so this line of code passes when these tests are omitted.
return arrayUpperCase.join(' ') + ' ' + arrayLowerCase.join(' ');
If there are only words that start with uppercase, there will be a trailing space and if there are only words that start with lowercase, there will be a space in front. These errors won't be spotted if these test cases are not generated.