DEV Community

loading...

Discussion on: Daily Challenge #276 - Unwanted Dollar Signs

Collapse
ptouchton profile image
ptouchton • Edited

This was my solution typescript/javascript

 const arr: Array<string> = ['12.34', '-0.89', '-$ 0.1','007','$-2.3456','$.2','$. 7'];

    console.log(`array: ${arr}`);

    const solve = xs => {

      xs.forEach(x => {

        const num = +x.replace(/[\$,' ']/g, '');
        console.log(`num: ${num}`);

      })
    }

    let me = solve(arr);

  }