Retired
Format a string of names like 'Bart, Lisa & Maggie'. (retired)
5,063 of 71,234weavermedia
Loading description...
Fundamentals
Strings
Data Types
Formatting
Algorithms
Logic
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.
is this solution considered any good?
This comment has been hidden.
This comment has been hidden.
The description with regards to the use of . or - is very very brief, should be a bit more detailed.
Submit button did not show
In Javascript version, my code passed all tests but the submit button did not show, so could not submit it. Anyone has the problem like this?
You can't submit in a Retired (or in a Draft) kata.
Thanks for your reply
Could you show me how to solve that problem?
There is nothing you can do, only solve katas that aren't retired or in draft. Approved and betas only.
I got it. I could not submit it because the challenge is retired.
Thanks again
Retired as a duplicate. See https://github.com/codewars/content-issues/issues/58.
I have an issue that seems related to the tests and not my code. I get this error if i return the correct string in attempt:
It should work for random tests too - Expected: ['Marge,', 'Barney,', 'Moe,', 'Lisa', '& Ned'], instead got: 'Marge, Barney, Moe, Lisa & Ned'
If I return the array instead of a string, all the random tests pass, but then i fail the basic tests which correctly ask for a string in return, am I missing something or it is just maybe a newly introduced bug with the tests?
Can't reproduce it, was it in javascript? Post your code as stated here: https://docs.codewars.com/training/troubleshooting#post-discourse
This comment has been hidden.
You, and the kata's author/translator used a
solution
var without declaring it (with var or let), that's the problem. I've fixed it in the testing part, I suggest you do that also in your code as good practice.Test Results: Test Passed: Value == 'Bart, Lisa, Maggie, Homer & Marge' Test Passed: Value == 'Bart, Lisa & Maggie' Test Passed: Value == 'Bart & Lisa' Test Passed: Value == 'Bart' Test Passed: Value == ''
However when I attempt: Must work with many names - Expected: 'Bart, Lisa, Maggie, Homer & Marge', instead got: 'Bart, Lisa, Maggie, Homer & Marge, ' Must work with many names - Expected: 'Bart, Lisa & Maggie', instead got: 'Bart, Lisa & Maggie, ' Must work with two names - Expected: 'Bart & Lisa', instead got: 'Bart & Lisa, ' Wrong output for a single name - Expected: 'Bart', instead got: 'Bart, ' Must work with no names - Expected: '', instead got: ', '
How did the tests work but 0/45 additional tests not work (especially ones that are the same)? When I run in code editor I get back the correct results I received in the test cases.
No idea without seeing your code, read this: https://docs.codewars.com/training/troubleshooting#post-discourse
This comment has been hidden.
The problem is you're using
for...in
, read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in and in the tests, the array prototype is modified.This comment has been hidden.
Hi. Please use spoiler flag next time. And please read this:
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Not a kata suggestion, please don't post solutions in Discourse.
the difficult is , and & boring
I think there's an issue with the test. It expects the sentence to end with a "," for multiple names. Anyone else experiencing this?
In javascript? No.
This comment has been hidden.
or it shouldn have these quots... I cant understand what is wrong...
Your code should return the string, not print it. https://docs.codewars.com/training/troubleshooting#expected-the-same
This comment has been hidden.
In your pc, you're using a different kind of input.
In Ruby, is it really necessary to use an array of hashes, all with the same key? Surely an array of strings would be sufficient…
This comment has been hidden.
Hi,
You've already been told 2 times to not post solutions in the discourse, by a power user and a mod... Tho you keep going... Any reason why?
Solutions of users are already visible in the solutions page. If anybody is interested in your solution, he can see it there. If you wanna show it to your allies/friends, there is a tab there "users I am following", or you can even send the direct link to your solution by email or anything.
If you keep ignoring the "warnings", you might end up with your account being trapped because you'll be considered a spammer. You don't want that...
Cheers
I'll change !
If you were trying to use the Javascript method .concat() like a was, here's where I was tripping up with it
concat does not alter the invoking strings, but returns a new one.
So you can't just iterate over the names array and concat the names to an empty string without reassigning the variable every time
This comment has been hidden.
In my case, I oriented to just such output
'Bart'
for a single name. And I got a valid result.The error message is only shown if your function doesn't return the right value.
so i wrote my code and it returned the excact same output as expected. but it still gives me an error. example it says, expected 'banana' but instead got 'banana'. meaning my code is correct but it is not been accepted as correct
is it possible you are missing a trailing whitespace?
yes i was! ive resolved that. but now my code passed 37 and is failing just 7. there is an error that says 'cannot read property 'name''. which i still cant figure out. the code is almost correct cos it passed 37. just cant figure out what the error is
that's because you can't read a property that is not present, consider the final sample test:
i thought its supposed to be present in the sample test arrays. so what do you suggest i do?
This comment has been hidden.
You need to return the result, not print it.
Yeah I was just printing it for debugging purposes. You can see the rest of my solution,but when I go on to iterate through new_names after using the second method it doesn't work because it is a NoneType
Well, I don't see where you declared
new_names
, so it's not surprising. But ok, let's say you did. Then,new_names = new_names.append(...)
- I really don't know how this should work, and it probably doesn't. My guess is that.append()
returnsNone
, so you re-assignednew_names
toNone
.I declared new_names in the first line I believe and you were right append returns None so that's where that came from. But let's say I did not assign new_names = new_names.append(...) and instead i just did new_names.append(...) I still get an error in the second to last line saying I can't concatonate generator objects... what is that? There is something I am not getting on why the two methods don't do the the same thing
Surround the thing you're appending in brackets: I think you're doing
.append(x for x...)
, but it should be.append([x for x...])
. The first is generator expression, and the second one is a list.This comment has been hidden.
Please don't post solutions to the discourse section, and if you must, use the
spoiler
flag.As for your question: Python code is nearly impossible to properly parse without proper formatting. Use Markdown to format your code. Also when you run the tests, they will typically tell you what is wrong with your result, i.e. what you returned and what was expected.
This comment has been hidden.
To discuss a solution, please, use
Solutions
section.I have my solution working with an array input that looks like ['Bart','Lisa','Maggie'] as opposed to the sample test format of [ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ]. I went in and changed the test format to what my code is expecting. If I click "attempt", will it fail on the full test? Do I need to adjust my code to accept the list with [{name: 'Bart'}] format?
Yes. You shouldn't change the sample tests to fit your code, it won't work that way.
I didn't realize at first that it had test scripts to validate the code. Now I know to look at the test scripts to understand the inputs. Thanks.
Hi there, I am pasing the test for (Format a string of names like 'Bart, Lisa & Maggie') kata one by one (changing the number of names in array) and Not all at once. Any suggestions? Big thanks in advance!
This comment has been hidden.
Your code is printing the result instead of returning it. Read this please: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
Thank you. That solved it.
that was fun. actually it can be done with a very simple code with 14 lines , trying to squeeze it.
This comment has been hidden.
You might want to squeeze it until one line :)
This comment has been hidden.
This comment has been hidden.
Code works fine but the console says its wrong :(
This comment has been hidden.
This comment has been hidden.
somebody knows how can I see my solution one more time? I've solved this task twice, and in the tab 'my solution' I have an empty page
In your profile there is the 'Solutions' tab.
not an issue
can anyone help me figure out how to add '&' and ',' between the names and at the end.
python?
This comment has been hidden.
I pass all the test but i get an error? how do i fix this
This comment has been hidden.
This comment has been hidden.
You have a problem with your global var, avoid using globals like that.
TypeError: Cannot read property 'name' of undefined at list at /home/codewarrior/index.js:40:19 at /runner/frameworks/javascript/cw-2.js:152:11 at Promise._execute at Promise._resolveFromExecutor at new Promise at Object.describe at /home/codewarrior/index.js:32:6 at /home/codewarrior/index.js:62:5 at Object.handleError
all my tests were successful but i dont understand tf is this. can someone pls help me?
In some place in your code the list it's not defined. You need to use names[index].name to access this property.
It would be great to validate before use those checkers. How are you using iterators?
This comment has been hidden.
You return at the very first iteration, and the first name is Bart in the tests.
You are only returning a name cause your aren't collecting the names. When you return z, you only retrieve the very last value of it. However, the "return z" expression is within the for cicle and it's executed in the first iteration. Hope help you!
I got undefined??
Log: 'Bart, Lisa, Maggie, Homer & Marge' Expected: 'Bart, Lisa, Maggie, Homer & Marge'
I also returned logged ouptut, what could be the problem?? Why is it saying undefined?
You're printing to the console.
Read this
I think you did not put spaces after the ", ". Or, there is a space after the answer.
This comment has been hidden.
And how exactly you go from list to string?
I'm using ', '.join() (python)
I'm getting something like: 'name1, name2 &, name3'.
This comma just after & is killing me!!! hehe :)
I have tryed to go back from string to list, and replace the element "&," to "&" , but it isn't so formal, I guess...
Oh, I got it. Not as formal as I wish, but It's working.
I used .replace("&,","&") hehe
You can use join method for all the items within the list except for the last one >>>> use slice notation and then insert the '&'
This comment has been hidden.
I never thought about it that way but also completed it in < 5 mins, thanks to regular expression.
This comment has been hidden.
Read your code again,
0 < 2
isn't it (it'll never enter your else if)? And when posting code like that, use markdown formatting and mark your post as having spoiler content.This comment has been hidden.
This comment has been hidden.
You have to
return
the result, notprint
it.shoot, I was testing things out by printing since I'm not too familar with dicts and I forgot to change the print to return. Thanks for pointing that out
This comment has been hidden.
Please, next time mark your post as having spoiler content and use markdown formatting so your code can be read exactly like you wrote it. Read the error message it says clearly what you're doing wrong and which test you're failing.
The python sample test cases are broken just because the author press the enter key in wrong place. The actual test cases are okay try them.
No, the sample tests work fine, what are you talking about? Click reset if you've modified them and check again.
I guess this Kata works wrong and my code works perfect:))
over twenty thousand coders have solved this kata in javascript, so nah
This comment has been hidden.
There are several errors there, the function's name should be
namelist
, that's why you get that error. Your function should return the result, not print it, and as you can see in the examples in the kata description, the size of the list is not always the same.thanks for your comment.i will review my code..
This comment has been hidden.
Don't post your code in discourse like that. It's forbidden.
This comment has been hidden.
Don't use for in with arrays: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
The author/translator decided to add a method to array prototype and that's causing your code to fail in final tests.
Sort of a strange way to store your names, but I guess it's all about knowing how to get neccesarry info out of it ^^
I feel like this is a test to see if you're capable of dealing with dumb instructions.
This comment has been hidden.
No one can help you without actually seeing your code (mark the post as having spoiler content if you do, also check how to use markdown formatting), what language are you using?
This comment has been hidden.
Make sure you choose 3.6.0 as Python version when using f-Strings.
My code is passing all the tests, but when I run an attempt I get the following exit error. What does this mean? The rb: line references are always the same - there is no line 10 in my code.
You're trying to access an item from a list on null (which obviously won't work).
CW put some other stuff in that file, it's not precise.
This comment has been hidden.
This comment has been hidden.
How did nashx90 format his comment so that his codeblock is separate?
and here's a link on proper code markdown with more info
this looked easy...but " , " this made me think twice>......
This comment has been hidden.
This comment has been hidden.
You don't need the quotes around the string, remove them.
This comment has been hidden.
names
is an array, not a string. Your first if does nothing.This comment has been hidden.
Not a kata issue, it's a problem with your code. Use question label next time. You're passing a list of strings as input in the last line instead of a list of dictionaries.
There is something wrong with the tests. Basic tests pass but when I hit "attempt" the same tests fail.
It's a problem with your code, read how for ... in works and the kata's author/translator modified the Array.prototype.
Thank you! it worked now.
please could you update the description to specify that the order of the names must be preserved? If order is not preserved, the kata does not pass, even though that should satisfy the description as it currently stands...
i have done my problem and test cases and my output is same.Shit its showing its not correct output i havee done everything satisfies test cases according to problem
This comment has been hidden.
WHY THE FUCK IS THE INPUT A LIST OF DICTIONARIES??????????
There's no reason to be upset at this, it's good practice. If you can't solve it simply, then, you need it.
This comment has been hidden.
you're multiple dicts withthe same key inside of a list inside a tuple is frankly just obnoxious.
What are "hashes of names" and what does it mean for them to be "pre-validated"?
Seems like more a question rather than issue
No, it's an issue with the description. It's incomprehensible. It should be edited.
Hey! Anyone know why my code prints it correctly only in the console.log?
In the test it shows: "Must work with many names - Expected: 'Bart, Lisa, Maggie, Homer & Marge', instead got: 'Bart, Lisa, Maggie, Homer, Marge & '"
Post your code with proper markdown and mark your post as having spoiler content.
This comment has been hidden.
Read this
Thank you very much!
This comment has been hidden.
The user can modify the "all available names" array in-between the tests in Python.
Also, I have no idea who came up with storing the strings as an array of dictionaries with a single
"name"
key, but (s)he surely has to pay for creating such an atrocity.Fixed
Sorry did I do something wrong.
This comment has been hidden.
This comment has been hidden.
Please don't raise an issue if there is a promblem with your code. Post a question instead. Also, make sure you flag your post as a spoiler if it contains your code.
Check your indenting.
Sure Avanta. Sorry for that I am a new member here. I dont know the rules. I just started couple of days ago.
I will make sure to follow the rules.
This comment has been hidden.
Don't modify the input.
I am not modifying any input. I dont know how to modify also. I am just modified the testcases for my testing.
The line,
k = m.popitem()
modifies the input.Pick one.
Don't use
.popitem()
because you're messing up the tests with it.Sure I will change my code and try again. Thanks again Avanta and FArekkusu.
I've fixed the test cases anyway, so your code should work now.
Thank you Avanta so much. It is working fine now.
if the names is an empty list, then f will be "-1". I think this will cause problem
let's get real: why is the input a list of single element hashes 🤢
Hi Folks, my basic tests pass, however the same basic tests are failing when I attempt the full suite of tests:
[ { name: 'Bart' }, { name: 'Lisa' }, { name: 'Maggie' }, { name: 'Homer' }, { name: 'Marge' } ]
---> Test Passed: Value == 'Bart, Lisa, Maggie, Homer & Marge'
[ { name: 'Bart' }, { name: 'Lisa' }, { name: 'Maggie' }, { name: 'Homer' }, { name: 'Marge' } ]
Must work with many names - Expected: 'Bart, Lisa, Maggie, Homer & Marge', instead got: 'Bart, Lisa, Maggie, Homer, Marge & '
JavaScript
This comment has been hidden.
Not a kata issue, it's a problem with your code. Check the test input, it has only one name, no wonder
names[countNames-2].name
will fail.there is an error. the basic tests work if I run on them, and if I press on "attemp", the basic tests fail.
on JS
It's working fine for me, and it has 11550 completions on js. Post your code with proper markdown and mark your post as having spoiler content.
.
Same here
Don't use
for ... in
with arrays.Isn't the whole point of dictionaries to use different key names?
This comment has been hidden.
This comment has been hidden.
Mark your post as having spoiler content (when you post code like this) and also check how to properly format it Read the MDN docs it's explained there.
Hmm I´m kind of stuck with this:
It should work for random tests too - Expected: 'Maggie, Ned, Homer, Barney, Moe, Marge, Bart, Seymour & Maude', instead got: 'Maggie, Ned, Homer, Barney, Moe, Marge, Bart, , Seymour & Maude'
But in the sample test it looks like this: Test Passed: Value == 'Bart, Lisa, Maggie, Homer & Marge'
I have used trim() and regex. It works when i try [{ name: 'Bart' }, { name: 'Lisa' }, { name: 'Maggie' }, { name: ' ' }, { name: 'Homer' }, { name: 'Marge' }] but not with the random tests.
Some hint would be nice :)
all tests pass except i get this error.
list': undefined method
+' for nil:NilClass (NoMethodError) fromblock in <main>' from
block in describe' frommeasure' from
describe' from `Must work with many names: 'Bart ,Lisa ,Maggie ,Homer & Marge' should equal 'Bart, Lisa, Maggie, Homer & Marge'
what is this error??? my code is really true'Bart ,Lisa ,Maggie ,Homer & Marge'
Not ok'Bart, Lisa, Maggie, Homer & Marge'
Ok Check where your commas are.thank you very much :D
the position of ","
Glad I finaly did this one. Accessing the name field was a nightmare until I worked it out LOL
congrats. I tried to print out the list and got the same required result. Then, I use return statement, but I still got the error:
Must work with many names: "'Bart, Lisa, Maggie, Homer & Marge'" should equal 'Bart, Lisa, Maggie, Homer & Marge'
Do you have any idea to fix the issue? Thank you
When I print the string, I put single quotation marks into the string. The issue is fixed by removing the single quotation marks in the string returned.
This comment has been hidden.
This comment has been hidden.
Log says: 'Bart, Lisa, Maggie, Homer & Marge' and I am returning the same result. Then why is the following error, when am not adding any extra bits? Must work with many names: "'Bart, Lisa, Maggie, Homer & Marge'" should equal 'Bart, Lisa, Maggie, Homer & Marge'
Thanks for any pointers.
I had the same issue. I was using print() for the output. When I used return, test cases passed.
@k2coder you had single and double quotes there, use only one kind.
Despite running my solution successfully in the console, codepen et al, still seems to be failing the test here.
You too? I thought I was going crazy! Must be an issue with the kata itself.
Or not.
Debuggug your code, print to the console. With more than thausends of completions, the problem isn't on the kata side, I'd bet.
I highly doubt this will be a spoiler, therefore I won't mark it as such:
I did prior to visiting this as a last resort; when the "names" object would be populated with, say, 5 objects (printed to verify), my count routine would say 6 for some reason, whereas when I ran the tests, my count routine, with the same format in the "names" object, would give me the correct amount, passing all of them.
Who knows, maybe we're missing something, or maybe it's been changed and accidentally broken recently.
post your current code with a spoiler, please, I'll take a look.
EDIT: It was just me being blind. I'll have that replied to you in just a moment. Disregard all of the below.
You might be a great person to help me with this:
How do I get back into the code after I have exited that screen? I might just be really, really blind at the moment but I can't seem to find a way.
Perhaps it isn't saved at all, and I'll have to write it again, but no worries on that!
This comment has been hidden.
Hu! that's really weird! I tried your code and found the same ehavior, yes. Unfortunately, I don't do JS, but here is what I found: in the attempt, your list has systematically 1 exceding empty element at the end
[ 'Bart', 'Lisa', 'Maggie', 'Homer', 'Marge', '' ]
, but I don't understand why. Seems related with the way you extract the names, but not knowing JS, I can't say more. I checked the test cases and the assertions are exactly the same than those in the sample tests, though.Really weird, but I have no answer for you sorry.
EDIT: Try to write your code without the
arrayName
array/list, I managed to pass the tests without it.This comment has been hidden.
@Avanta: yeah, that's it. But the real question is (to me), why doing it this way cause the extra element at the end? Do you know? (Note: with a spoiler flag, he cannot read your comment. / @ DuhbleB: it's almost the same than mine, anyway (well in a more explicit manner, yes ;) )
This comment has been hidden.
Ha yeah. Seems the tests aren't made the better way, so. Too bad there are already too much completions to modify them...
Hey, thanks to all of you for helping out! I don't do JS either that much, much more a C family guy, so any help at all is good!
I'll try the rewrite suggested.
Good luck :)
Found this on SO:
'for..in will loop over all own and inherited properties of the array object which aren't DontEnum; that means if someone adds properties to the specific array object (there are valid reasons for this - I've done so myself) or changed Array.prototype (which is considered bad practice in code which is supposed to work well with other scripts), these properties will be iterated over as well; inherited properties can be excluded by checking hasOwnProperty(), but that won't help you with properties set in the array object itself.'
So thats why it was counting 'shuffle' and adding the extra element.
I think that you could have used a 'for...of' loop and it would have worked.
TypeError: Cannot read property 'name' of undefined at list at Object.handleError at ContextifyScript.Script.runInThisContext at Object.runInThisContext
This comment has been hidden.
Why I got: undefined?????
Log: 'Bart, Lisa, Maggie, Homer & Marge' Expected: 'Bart, Lisa, Maggie, Homer & Marge'
instead got: undefined
You have to return it if you logged it...
Answered.
This comment has been hidden.
return
mensaje
instead of printing it to the console using console.log. Undefined is the default value when nothing is returned.@weavermedia, thanks for nice kata! Cheers!
Is it really necessary to pass a list of dicts? surely a list of strings would have tested the same skills. names[-1]['name']... makes my eyes hurt.
sorry for the noob question, but why access items from the -1 index?? wouldn't that give an out of bounds exception?
In Python you can use [-1] as the index to a list to access the first item from the right.
This stumped me for a lot longer than it should have done! Particularly as I forgot how to iterate properly...
Wow nice keta !The first thought in my mind of this keta is about regex . I thought it would be easy to crack and it turned out not to be the case ...
I just wanna know what the hell’s the type of the given data!
Really nice kata
Cptn, mission completed.
This comment has been hidden.
The description gives the example:
You must return an empty string if an empty list is given as the parameter. You know you can print the input parameter to the console, right? Your code fails because it attempts to pop from the empty list, leading to an error.
To control formatting of code in the comments, you need to use markdown, see here: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting
This comment has been hidden.
This comment has been hidden.
passing site test example but then i get
when i run suite >>
list': undefined method
join' for nil:NilClass (NoMethodError) Did you mean? JSON fromblock in ' from
block in describe' frommeasure' from
describe' from ` ' not sure whats upBeing somewhat new to coding this was an excellent Kata, learned a lot and had to think through new ways to doing things. Bravo!
The dicts seems superfluous, why not just give an array of names?
This comment has been hidden.
The length of an object is one higher than the last index, since they are zero-indexed.
i
starts at the length of the object and this doesn't exist as an index. Example: length = 8, names[8].name -> returns undefined because there isn't an 8th index.Each iteration will currently overwrite the value of var 'result'.
You need the '+=' operator:
Thus you're not considering some conditions:
Good luck and do your best!
This comment has been hidden.
Hello, I pass the initial tests but not the submission tests. It seems some functions for manipulateing arrays are not working in submission? Not sure how to articulate without writing code. When I log values to the console I can see that built in array manipulation functions are not available during submission because arrays are not affected by them where as they are available in the initial tests.
I solved this challenge and my submission is passing all tests but it's not letting me submit for honor and look at others' solutions unless i forfeit honor, which i don't want to do since i solved it fair and square
RIP Oxford Comma
looks like a syntax error in testing: (python) at & char
No problem found.
I guess I am hitting the same error as Itison:
Trying to get the right formatting ... not sure if it points to the
&
or the space behind.This comment has been hidden.
I have returned and used console.log for my output string...it looks identical to the test cases but will not accept. any help would be awesome!
What's the deal with this Kata? All tests pass, except test for null array, where I get back:
✘ Must work with no names - Expected: , instead got: ,
What's the differnece between , and , ?
I think there is a difference between "" and ","
This comment has been hidden.
can somebody tell me about why the reduce() function will return the object.name, if there is only one element in array?
i have do the search in MDN, but nothing help!
I have no idea why this is not correct. Must work with many names - Expected: Bart, Lisa, Maggie, Homer & Marge, instead got: Bart, Lisa, Maggie, Homer & Marge
I even used trim() to make sure I didn't have any extra spaces at the beginning or end. Any ideas?
You probably try to print result instead of returning it
Do you fixeded it?I have the same problem.
I have the same problem. I try to print it out. I think the result is correct. But I still get the problem
Must work with many names: "'Bart, Lisa, Maggie, Homer & Marge'" should equal 'Bart, Lisa, Maggie, Homer & Marge'
I don't know how to fix this. Did you fix it?
@LinhLoc : Why the double and single quotes? One kind is enough.
Why does it say incorrect?!
Basic tests Bart, Lisa, Maggie, Homer & Marge Must work with many names: None should equal 'Bart, Lisa, Maggie, Homer & Marge'
You probably try to print result instead of returning it
This comment has been hidden.
Try to add "return result;"at the end of function codes?
I dont know what's wrong with this Must work with many names - Expected: Bart, Lisa, Maggie, Homer & Marge, instead got: Bart, Lisa, Maggie, Homer & Marge It looks the same for me. I check the type of the return value and it is string.
Check that you don't have an extra space in the output string. I had that problem, it's hard to spot.
I still have this problem,,,,,,,,, I don't know whats the problem
This comment has been hidden.
i am having the same problem, did you figure out what was wrong with your code? i got this error= (Expected: Bart, Lisa, Maggie, Homer & Marge, instead got: Bart, Lisa, Maggie, Homer & Marge) i don't know what the difference is, i don't see different spaces or anything. Could someone please help?
i have space in the end. so i use trim for the result
I think it's very easy for 6kyu
This comment has been hidden.
Looks like there are too many test cases. I get this error: "Max Buffer reached: Too much information has been written to stdout."
My code doesn't write anything to stdout.
I think there is a problem with this kata. My code completes all the test cases but when i try to submit it passess all except the empty list, which my code returns an empty string for. The error just gives " Expected: , instead got: , " so i have no idea what to do. I tried to return null and empty arrays but none worked:/
edit. i got it to work, it had to do with the object name being empty instead of just empty array:) Maybe give better info on the fail event it was really dumb trying to figure what's wrong when i felt it should have worked
Added sample and random test cases for Ruby (so any language now has some); if anything goes wrong, it is of course my fault, so let me know and I'll try my best to fix it :)
Translated into both JS and Python with lots of random tests, if you want to approve it :)
This comment has been hidden.
I think there should be test cases for when the name contains a separator character.
There is a note at the end of the kata that said Note: all the hashes are pre-validated and will only contain A-Z, a-z, '-' and '.'. So it is not necessary to check if the names have separators.
Some random test cases please, just to prevent cheating?
I added them now, in case you may still want to appreciate it :)
I hope for better Test failure messages, like "I expected list([]) to equal "", but your method returned nil".
I've improved the test failure messages.
Thanks for your feedback.
This comment has been hidden.
It returns Success when it isn't.
Oops, bad syntax in my test cases! Fixed and re-published.
Thanks for looking.
how can i write test?? Test.assert_equals( list([ {name: 'Bart'} ]), 'Bart') or Test.assert_equals( list([ {name: 'Bart'} ]), "should return 'Bart'"). Thank u very much!
I've made the instruction wording clearer.
Thanks for your feedback.