How to check if the string has numbers in Javascript
I need a function that takes an array of strings and returns an array with only the strings that have numbers in them. If there are no strings containing numbers, return an empty array.
1 Answer
this function will return an array with only the strings that have numbers in them
function numInStr(arr) {
return arr.filter(str => str.match(/[0-9]/) !== null);
}
answer Link