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.
It's a recursive solution. The condition checks to see if the string ends in an exclamation point. If it does, then the string gets the last character removed and it gets run through the
remove
function again. This way, the last exclamation point keeps getting removed.Finally, once all the recursive calls are made, the ternary will return the string without any exclamation points at the end.
I hope that makes sense, but if not, just know it's a recursive function and look up what that means and see some examples. Then it will make sense. Good luck!
developer choice, but its not needed and will be omitted
Great explanation. No need to worry about mutation of the original input as strings are primitive data types, i.e. passed by value. We are passing the value of the original string as a parameter and it is being stored in the local variable 's'. Thereafter, we are manipulating the local variable 's' so the original string remains the same.
This comment is hidden because it contains spoiler information about the solution