

function getNumberFromName(name: string) {

    name = name + ' '

    let number: any[] = name.split('') 

    let newNumber: any = ''
    let list = []

    for (let i = 0; i < number.length; i++) {

        if (!isNaN(Number(number[i])) && number[i].trim().length > 0) {
            newNumber += number[i]
        }
        else {
            if (!isNaN(Number(newNumber)) && newNumber.trim().length > 0) {
                list.push(newNumber)
            }
            newNumber = ''
        }
    }

    // longestString = list.filter(str => str.length === Math.max(...list.map(s => s.length)))[0];

    // console.log('list: ', list)


    let longestString = ""; // variable to store the longest string
    for (let i = 0; i < list.length; i++) {
        if (list[i].length > longestString.length) {
            longestString = list[i];
        }
    }

    return longestString
}

export default getNumberFromName;
