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.
the C code has been updated
Does your code pass the other tests?
People trying to solve the problem in "C" have noticed immutable memory being used, even though the argument type passed in is for a mutable string.
I think what you see is "honors". Honors give you ranks and privileges. See:
https://github.com/Codewars/codewars.com/wiki/Honor-&-Ranks
https://github.com/Codewars/codewars.com/wiki/Privileges
Badges are already earned when you get enough honors. They are shown in the "Profile badges" section accessible by pushing the "View Profile Badges" button in your profile page.
I suggest a test to add. Motivation: if an HTML input string already contains "&", you don't want to transform it into "&";
describe("Solution", function(){
it("@amp;", function(){
Test.assertEquals(htmlspecialchars("&"), "&", "the & in the already correct substrings should not change");
});
});
OK the answer to my own question is: yes, strings in JS and TS are immutable, that is, once created, their internal state cannot be changed.
Functions that operate on a string in fact return new strings.
My solution would work even if I do not create a new string to compute the result.
@rowcased take a look at this ^
This comment is hidden because it contains spoiler information about the solution