Obviously mine is longer than most, but I want to only produce readable code. I also added some extra bits like trimming whitespace and checking for empty items, as we know User's will input all sorts of things.
I also just have a general aversion to writing Regex as it's not understandable by many.
That said, looking at everyone elses solutions, I should have leveraged string.replace()!
This comment is hidden because it contains spoiler information about the solution
technically correct is the best kind of correct...
Best by far
You can call 'length' on a string, no need to split it! :)
I see that now, I wasn't thinking xD
This comment is hidden because it contains spoiler information about the solution
Obviously mine is longer than most, but I want to only produce readable code. I also added some extra bits like trimming whitespace and checking for empty items, as we know User's will input all sorts of things.
I also just have a general aversion to writing Regex as it's not understandable by many.
That said, looking at everyone elses solutions, I should have leveraged string.replace()!