Draft
Sparse array to dense array
844sQuare
Loading description...
Fundamentals
Arrays
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 comment has been hidden.
Added a test with a letter in it, hopefully it'll fix it.
Tests chceck only integer values.
Added a test with a letter in it, hopefully it'll fix it.
This comment has been hidden.
Not a kata issue, it's your code what's wrong there. When you use a global var, it keeps its values on the next function call, so you get wrong results, in call 2, 3 and so on. Making newArray a local var will solve your problem.
Inappropriate tags (object-oriented?)
.
needs to explain what a sparse/dense array is more specifically
"Note: the function must ignore undefined and null values."
The example code provided is a bit ambiguous about the function used when it says
console.log(function(sparse));
sparce
is defined on the line right before that one.Could give a defined way to do this: rather than just a forEach...
The approach is up to the user, that isn't an issue.
The values that must be filtered out of the array are not as clear as they could be. There should be a clear definition for both "Sparse" and "Dense" arrays provided in the directions
I have been getting tired of the one-liners here.. but for some reason I like this one :)
Why wouldnt my code work ? isnt 0 a number and null an object so why wouldnt it display 0 ? so confused
If you posted the code it might be possible to answer.
Should contain some random tests, or at least tests with random order.
timeouts :(
You should add a test with 0 values, that will prevent solutions like mine to pass.
Added the test as you suggested. Thanks for the feedback!
This comment has been hidden.
I'll edit the kata after a little nap. It's been 20-ish hourse I've been awake. Thanks for the feedback!
Good job!