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.
Thank you for your help, it's alot clearer now.
It rounds down, read this: https://beginnersbook.com/2013/12/java-string-substring-method-example/
You also have to return 1 (if length is odd) or 2 (if it isn't) letters only.
If you mean you're returning the whole
testing
string when the input is alsotesting
being:That's how the testing framework works, it won't matter where the
t
came from, it's comparing 2 strings and the difference between one and the other is the expected only has at
and the returned (when returningtesting
) hasesting
after thet
. Nohing to fix there.Go back into the question and use word.substring(0) and tell me what appears in the brackets.
wouldn't we assume,
[0] = T , [1] = E , [2] = S, [3] = T , [4] = I , [5] = N , [6] = G
Therefore if word.substring(0) should start from position [0] including itself so it would return testing
And if we wanted the middle character for odd,
word.substring(word.length()/2 ) <--- wouldn't that be the substring from index [4] being I, not T ? 7/2 =3.5 and I would assume it rounds up? Or is that incorrect thinking would it round down on decimals to index places? Is that what it usually does?
It's a problem with your code, the expected value for
testing
ist
(the middle one):There is a problem with the question, If you do the question in Java and for the odd questions testing only return word.substring(0);
It should return the full test word back as a check, it only returns [esting] Which is incorrect with how the substring works and the indexing of the letters.
This needs to be fixed.