I am working on creating a unique filter that can extract numbers from text input into a text box. For example:
User enters: The cat went to 4 stores and bought 3 bags of cat litter for 1 dollar.
The desired output would be: [4, 3, 1]
This filter works by analyzing the previously filtered array ['the', 'cat', 'went', 'to', '4' ...]
My approach involves utilizing a for loop to iterate through the array and identify numerical values. However, uncommenting the for loop causes issues within the application. Any suggestions or assistance would be greatly appreciated.
filter('showNum', function() {
// this filter is not complete but it will return only numbers from an array
return function isNumeric(title){
var numbers, i, len, numberToAdd;
numbers = [];
len = title.length;
// for(i=0; i<len; i+=1){
// numberToAdd = title[i];
// if(!isNAN(numberToAdd)===False); {numbers.push(numberToAdd);}
return numbers;
};
})