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.
I can't tell what language you are using. At first, I thought it may be JavaScript ( but I see you have a lower case "null". However, if it was JavaScript, when using the .sort() method, the array components are converted to strings. In that case, "1" will be followed by "10". To compare numbers, you need a call back comparison function within the method. Might be some case like this for the language you are using. Besides that error, did the message log out your returned result?
It also depends if a person solves it by scratch and not by using built-in or imported sorting functions or methods.
Awesome thanks!
I tried this in Csh and it failed the test cases, but unless I'm missing something, it passes the example cases in the terminal. Can you confirm that this will work with Csh?
This solution is time O(n), so a best practice solution. Many others, including my first attempt are O(n^2)
I suggest rewording the description for JavaScript from: "Write a class function named repeat()" to "Write a function named repeat()", because even though the problem starts with
function repeater()
, someone may believe the solution was supposed to start with theclass
keyword, or take the form of a method under a class constructor.In JavaScript, .join() is an Array method, not a String method.
To put two strings together, you would use the .concat() method, or use the "+" operator.
Just curious, what is the danger in using
for...in
with arrays?Ha yeah, actually it was a really good practice exercise for a shell one-liner...
:)
This comment is hidden because it contains spoiler information about the solution