7 kyu
Count strings in objects
6,800franzmoro88
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.
This kata forced me to learn about recursion, awesome!
This comment has been hidden.
You're not handling nested objects correctly.
Can I see all possible test cases anywhere? I don't understand the kata's description. I tried to see an object as argument in the console, but I saw arrays too. What is that??? I see in the description => strCount (takes an object as argument)... ><
You can use console.log(obj)
Brilliant kata for understanding of recursion. Spent few hours figuring out how rec funcs work. Even after solving havent fully grasped it.
This comment has been hidden.
Hello! Thank you for this kata. Although, I'd suggest to describe task more clearly, because when you try to complete this based on description and sample object the solution could past the basic test... but when it comes to 'Attempt' kata requirements becomes super unclear. Something like '...takes an object as argument that can consist of some levels of nesting with nested object and arrays and(or) array of objects etc.' or more descriptive example. It would clarify requirements a lot.
if I copy in VS it underlines symbol ':' and writes "expected ;" andyou: [Function: andyou] wtf is it ???!!
OP solved it, closing
Hello! I'm sorry, but what is it - andyou: [Function: andyou]? I take this object to my VScode and I get an error. Sorry for my English.
{ one: '1', two: 2, three: false, four: {}, another: '3', andit: [], andyou: [Function: andyou], whatabout: { andone: 'and another', andtwo: 2, andthree: 'and again' }, lastkey: [ [ [Array], false ], 0 ] }
Somebody, please. I also need an explanation
OP solved it, closing
why this test expect 5 instead of 4??
This comment has been hidden.
This comment has been hidden.
...
andyou: [Function: andyou],
This is the wrong entry in the array, right? Why is she in the test?
OP solved it, closing
I feel emberessed that i cant even solve object 7kyu....
This comment has been hidden.
Because it depends on Node's version.
I've enabled Node 14, copy your code, click reset to refresh the tests and try again. Make sure Node 14 is selected.
JS: Node v12 should be used along with the appropriate assertion tools (Mocha + Chai)
Done. The tests could be improved tho.
This comment has been hidden.
it's very helpful, but not required. You can solve the kata without recursion if you wish.
This was fun! Thanks
THANK YOU FOR GIVING ME A DIFFICULT TIME IN THE BEGINING NOW I WAS INTRODUCED TO RECURSION WOHOOOOOOO!!
This kata actually offers a relatively simple introduction to recursion for someone who has never used it before - like me!
This comment has been hidden.
Hello, I submitted a solution that works in the first 2 test cases but doesn't in the last one. I get the error message: "Did not count the correct number of items. - Expected: 6, instead got: 5"
I can't find what's wrong, can I see the third test case to check where exactly the problem is?
Thanks in advance!
You can use console.log(obj) as first line in your function to see/use the input object of this last testcase. Now for example you can create your own testcase using/inserting this output- object in the editor (test block) too (so you not need to hit submit every time)...
Thanks! Sorry for the late reply, I didn't have time to come back to this kata :) I tried it and I found where the missing string is. Let's hope I can solve it now :D Cheers!
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Thank you. Is there really a 7 kyu level question? I must really suck with Objects then. I cannot seem to get this... Time to move on for now.
This comment has been hidden.
This comment has been hidden.
I submitted a solution that seems to work, and it passes 2 of the tests but seems to fail the last. I ended up viewing the test cases, and tested each case individually and they all return the correct number of strings. I'm using a recursive function.
This comment has been hidden.
Needs random test cases
Added random test cases. Please let me know if they work for you. Sorry, but I'm inexperienced with testing, the framework and kata-making.
All good! :)
Your test cases are very broken, I cannot even submit because it throws an error...
The test cases are pretty straightforward. The function strCount() is called various times taking different objects as arguments, and expecting the function to count all strings inside of it. What is the problem?
The problem is when I submit I receive this error
kata: Unexpected token:26 [[undefined,"and again"],false],0]),5,"Did not count the correct number of items."); ^
Also I had to manually fix the default test case (missing a comma) to test it in the first place.I fixed the test cases. Thanks for spotting out the issue!