jeudi 15 octobre 2020

Test for n digits in a string

I am trying to solve 'JavaScript Algorithms and Data Structures Projects: Telephone Number Validator' @freeCodeCamp.

I need to test if string contains 10 digits and what I've come up with returns false and I don't understand why.

console.log(/\d{10}/g.test("555-555-5555"))

Aucun commentaire:

Enregistrer un commentaire