Beta
Check phone numbers
Loading description...
Regular Expressions
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.
Testing is inadequate.
This solution is buggy: it might give a false negative ( I think. might be a positive ) when the local number starts with the area code. But it passed the tests anyway.
Add a test with
0891111111
in the phonebook and0891111
as the new number.Thank you for suggestion. I added this test case to the fixed tests.
This is wrong too.
However it worked, but I changed it to this:
let phoneBookLength = Math.floor(Math.random() * 8+2); for (let i = 0; i < phoneBookLength; i++) {
Well,
Math.floor(Math.random()
will always be0
¯\_(ツ)_/¯You are right, it worked not as suppoused. Now it is OK.
It seems the usage of country code and area code are completely irrelevant in this kata. So different area codes and/or country codes are not tested?
Actually it is supposed to be an easy kata. Different country and area codes are not tested.
Then pls mention it in the description.
Added
I have a partial solution that passes sometimes. These are the tests that would fail my code. You need more coverage to fail a partially correct solution.
/* Phonebook: 0049(89)0 38-78 9-6, 0049(0)894194 2 46, +49(0)894 2 01 74 9, 6 8-0-1-745, 76-77-90-5. New number: 0 3 8-7 89-6 expected true to deeply equal false Expected Actual false
Phonebook: 0049(89)0-25 0 3-50, 0049894-74-2 12-0. New number: 0-2-5-03-50 expected true to deeply equal false Expected Actual false
Phonebook: 00-8-5 3-3 1. New number: 0(89)0-08 5 3 3 1 expected true to deeply equal false Expected Actual false */
EDIT: thses are cases where the 7-digit number has leading zeroes. So, at least put one in your fixed tests.
I added this case to the fixed tests.
You're slicing away the last element of the array. And you don't need to use both slicing and spreading to copy the array.
It was made for purpose. If I don't slice it, the new number will be always in the phonebook.
You are right. The spreading was needless. I removed it.
But
newNum
is generated separately, it's never in the phonebook.The newNum is always one of numbers from the array randomNumbers. If newNum gets onto the last position, it can be added to the phonebook, because it was sliced before. Separately are generated only dashes, spaces, country and area codes.
This code is wrong.
This code provides an array of random length from 2 to 9. What is wrong with it?
In each loop a different random number is calculated. You should use a var and generate the random number before the loop.
Oh, I see. I corrected it. Thank you.
The country and area code can be written in different art or can be missing.
What is a country code? What is an area code? These are not defined for the kata. What do you mean bydifferent art
? Art?I don't think, that there is any need to explain this. The examples are self-explanatory. Also it supposed to be a little puzzle. The user needs to think a little before to start coding.
No, this is not a puzzle kata. Omitting specs and leaving them up to the coder is a giant, pointless annoyance. This would be easy for you to fix and makes your kata more appreciated. Also, whatever you meant by the word
art
is not yet explained. It's not a correct usage of the word.OK. I trust your experience. I changed 'art' to 'manner' and added additional explanations about the country and area codes. Is it OK now?
That's great, thanks for your consideration.
Thank you for help.
No problem, one small correction:
code can be written in different manner
should becode can be written in a different manner
.Corrected.