How to use .match for a integer?

Not a string so is display error on load.

TypeError: string.match is not a function

// initializing function to demonstrate match() 
// method with "g" para 
function matchString() { 
    //var string = "Welcome to freecodecamp"; 
    var string = 1243534543;
    var result = string.match(/d/g); 
    document.write("Output : " + result); 
} matchString(); 

https://jsfiddle.net/e1zo72b9/

Thanks!

12343534543 is not a string. All you need to do is set string to "1243534543" instead.

2 Likes

Still need a \ char before d so \d

// initializing function to demonstrate match() 
// method with "g" para 
function matchString() { 
    //var string = "Welcome to freecodecamp"; 
    var string = "1243534543";
    var result = string.match(/\d/g); 
    document.write("Output : " + result); 
} matchString();