6 kyu
"TRaduttore".tr( [ "u", "tt" ] , "it" )
254ZozoFouchtra
Loading description...
Strings
Arrays
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
the fact that
toList
can also contain integers is not mentioned in the description. i would either remove this test case or add the special case of integers to the discription.This comment has been hidden.
I'm getting a weird error on only one test case, the same if I return 'this' unchanged: No match, should return original string - Expected: 'H}[[() Y()u H#ppy K#+# S()[v}r', instead got: [String: 'H}[[() Y()u H#ppy K#+# S()[v}r']
Is this correct? If so, could I get an explanation? A (dumb) workaround is returning directly 'H}[[() Y()u H#ppy K#+# S()[v}r'
The suggestion below is actually an issue.
There are many solutions that iterate the pairs sequentially. How about some tests like 'abc' => 'bcd'?
Erm..
No match, should return original string - Expected: H}[[() Y()u H#ppy K#+# S()[v}r, instead got: "H}[[() Y()u H#ppy K#+# S()[v}r"
I'm returning the original string in that case..
I'm having a hard time getting the special character tests to work. I believe the parens in the first special chars test is what is screwing me up. The argument is: ( H}[[() Y()u H#ppy K#+# S()[v}r )
But when I assign "this" to another variable... I get: H}[[() Y()u H#ppy K#+# S()[v}r
Notice the opening/closing parens are missing.
Can anyone point me in the right direction on how to account for this scenario?
P.S. Is it ok for me to post my code here?
You're right, the tested string there is
H}[[() Y()u H#ppy K#+# S()[v}r
(without outter parens). Is then tested against variousfromList
,toList
, eg:...and so on
hope it helps.
P.S. If you want to post your code you should mark it as spoiler ( you'll can no more read it but warriors who have solved it will can.)
escSpecialCh
whentoList
is defined, not whentoList
is undefined. Are you sure there will be no special chars infromList
whentoList
is undefined ? (hint: the answer is no, you shouldn't be sure!)May the Code be with you
Yea, I figured that out shortly after I posted that comment, so I deleted it. At first I thought I was somehow causing a memory leak or something that was producing garbage, but then I saw that you were actually trying to help us by displaying the string. It threw me off because you didn't do that with the other tests.
Oh... My... God... I don't even know how I didn't notice that.
Thank you very much for your help Zozo
Playing with RegExp and escaping is fun, but also a hugh kidney stone. Oh man, I spent some agonizing minutes passing this stuff.
I also see my solution wasn't as elegant as others. Made the kidney stone even bigger.
I don't think tr is a good name for this method. Makes me think of html tag. What about naming the method "trans" or "translate"?
In fact, my idea was rather to evoke the Unix command (https://en.wikipedia.org/wiki/Tr_%28Unix%29) of the same name.
Ah, cool, makes sense. Might be nice, not necessary, to include a little blurb about tr being a watered down version of the Unix command to spread some knowledge.
"blurb" added.
Nice and straightforward. Passed all the tests (went with a regex/replace-function solution). Couldn't get the "Last words" to log, though?
"Last Words" console.logged after all test-cases.
Oh, cool. Still not seeing anything, though:
(copy/pasted from log frame)
Oh, oh! It does seem that your solution fails to translate the "Last words". Should I include them as a "Last test" ?
Probably should, yeah. Or include the same edge cases in other tests.
Godd it figured out, now. It was the "." that was tripping me up. Best add that (and the "|" too?) to some tests.
Thanks for your help.
Ok. I added some more tests about some special characters more (
|
,*
,.
). Added the " Last test " too ( with a message-error ..mhm.. not so helpful )