For example, I have a string "asdf123d6lkj006m90" and I need the following result [123, 6, 0, 0, 6, 90]. I tried:
let str = "asdf123d6lkj006m90"
let func = function(inputString){
let outputArray = []
let currentNumber = ""
for(let element of inputString){
if(Number(element)||element == 0){
outputArray.push(Number(element))
}
}
return(outputArray)
}
console.log(func(str))
But it returns [ 1, 2, 3, 6, 0, 0, 6, 9, 0 ] How do I receive the correct numbers?
0s part is confusing, and that's not what a regex would return either.