Ad
  • Custom User Avatar

    I don't understand why this works. I first tried to do it my own way and I got a few errors. Then I tried this code and it says it's good, but if I test it for use cases my code failed, you still get the wrong answer but still pass the problem somehow.

    My code failed for those 2, but your code wors fine even if still fails. Why?
    console.log(createPhoneNumber(['(', 1, 2, 3, 4, ')', ' ', 5, 6, 7, '-', 8, 9, 0])); // ((12) 34)- 567
    console.log(createPhoneNumber(['(', 1, 2, 3, 4, ')', ' ', 5, 6, 7, 8, 9, '-', 0])); // ((12) 34)- 567