Beta

Check phone numbers

Description
Loading description...
Regular Expressions
Fundamentals
  • Please sign in or sign up to leave a comment.
  • JohanWiltink Avatar

    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 and 0891111 as the new number.

  • FArekkusu Avatar
    let phoneBookLength = Math.floor(Math.random());
    

    This is wrong too.

  • docgunthrop Avatar

    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?

  • rowcased Avatar

    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.

  • FArekkusu Avatar
    it(`Phonebook: ${phoneBook.slice(0, -1).join(', ')}. New number:  ${newNum}`, function() {
      assert.deepEqual(checkPhoneNumber([...phoneBook.slice(0, -1)], newNum), checkPhoneNumberTest([...phoneBook.slice(0, -1)], newNum));
    });
    

    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.

    • juggler39 Avatar

      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.

      Issue marked resolved by juggler39 5 years ago
    • FArekkusu Avatar

      If I don't slice it, the new number will be always in the phonebook

      But newNum is generated separately, it's never in the phonebook.

    • juggler39 Avatar

      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.

  • FArekkusu Avatar

    for (let i=0;i<Math.floor(Math.random() * 8+2);i++)

    This code is wrong.

  • rowcased Avatar

    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 by different art? Art?

    • juggler39 Avatar

      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.

      Issue marked resolved by juggler39 5 years ago
    • rowcased Avatar

      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.

    • juggler39 Avatar

      OK. I trust your experience. I changed 'art' to 'manner' and added additional explanations about the country and area codes. Is it OK now?

    • rowcased Avatar

      That's great, thanks for your consideration.

    • juggler39 Avatar

      Thank you for help.

    • rowcased Avatar

      No problem, one small correction: code can be written in different manner should be code can be written in a different manner.

    • juggler39 Avatar

      Corrected.