Trying to find numbers in my String then store those values in a variable for use in math : Basically ive had a easy time at this so far because ive been just useing userInput.includes() then the word then what happens if the word is typed. I want to make it so the user can put like add 2 numbers together. So then my program would store that 2 make 2 variables then make a adding function. My big issue is finding the integer in a string and storing it in a variable.

     function hasNumbers(t)
    {
    var regex = /\d/g;
    return regex.test(t);
    }    

something like this would be good but id prefer it not to be a function. ether like var amountOfVariables =    or if(userInput.includes,isinteger,typeof, etc there has to be a combination of methods that allows you to find a integer in a string. then stores it in a variable
was trying to use
       document.write(amountOfVariables); 
to test if it was being stored but no luck. I know i need to convert the String part into a int.

Example of a user input might be " make a C++ program that adds 2 numbers together"     the 2 should be stored in whatever variable .
I want a method or a way to store integers in a users input in variables for later use in functions. But at the moment I cant get this to work.
