I got rejected in tech screen yesterday. I was asked to write a JavaScript function and send it over email. The question was(I have added the full question below). I have also added hiring manager's response at the bottom.:
Could you please write a JavaScript function to compare two strings that look like phone numbers and indicate whether the digits in both strings match? (To be clear, while the input looks like phone numbers, this question doesn't care how phones/telephony/dialing works.) Your code should compare only the digits of the input, ignore any letters or punctuation, and ignore the fact that country/area codes can be optional. As an example, "(123) 456-7890" and "123.456.7890" match because both have the digits "1234567890" in that order, while "1-123-456-7890" and "123-456-7890" do not match (even though they'll probably reach the same person if dialed in the US).
I wasn’twasn't sure if regex would be an acceptable solution so I implemented it two ways; pleaseways. Please, let me know what I could have done better.
The full question is - Could you please write a JavaScript function to compare two strings that look like phone numbers and indicate whether the digits in both strings match? (To be clear, while the input looks like phone numbers, this question doesn't care how phones/telephony/dialing works.) Your code should compare only the digits of the input, ignore any letters or punctuation, and ignore the fact that country/area codes can be optional. As an example, "(123) 456-7890" and "123.456.7890" match because both have the digits "1234567890" in that order, while "1-123-456-7890" and "123-456-7890" do not match (even though they'll probably reach the same person if dialed in the US).
The response that I got back from the hiring manager was: Thanks! I've looked over your code and think you captured the essence of the problem correctly. I like that you included both approaches - I prefer the _compNumbersUsingRegex implementation which is basically the one I like to see (regex+compare). That said, your resume shows you've been working with JavaScript in your current role, but some of the patterns I see in your code aren't quite in line with what I look for from senior developers on the team, so this role might not be the perfect match for you.
Thanks! I've looked over your code and think you captured the essence of the problem correctly. I like that you included both approaches - I prefer the _compNumbersUsingRegex implementation which is basically the one I like to see (regex+compare). That said, your resume shows you've been working with JavaScript in your current role, but some of the patterns I see in your code aren't quite in line with what I look for from senior developers on the team, so this role might not be the perfect match for you.