'Converting string to int in javascript returns NaN

I am trying to convert a phone number on a web page into an integer value but it repeatedly returns NaN, despite being a number. This is part of a chrome extension. My code is as follows:

currNum = String(document.getElementsByClassName("number")[0].innerHTML).trim()
console.log("First: " + currNum)

currNum = currNum.replace("(","").replace(")","").replace("-","").replace(" ","")
console.log("Second: " + currNum)

currNum = parseInt(currNum)
console.log("Third: " + currNum)

The logged output is:

‪First: ‪(206) 000-0000
Second: ‪2060000000
Third: ‪NaN

Is there something about this number that can't be cast to an int?

Thanks



Solution 1:[1]

currNum = currNum.replace(/[\s()-]/g, '')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tenshi