I am using third party API, that API provide the response provided the value with currency type,
Sample Input : £200000
Expected Output: £200,000
I tried to change the format, but unable to achieve the output.
var sampleInput = '£200000';
var x = convertCurrencyValue(sampleInput);
document.getElementById('test').innerHTML = x;
function convertCurrencyValue(input) {
var getValue = input.replace(/&/ig, "&");
var myValue=parseInt(getValue.replace( /^\D+/g, ''));
return myValue.toLocaleString();
}
<div id="test"> </div>
Note: The currency is not static, it will change based on input. so need to display the value based on input.
I know i didn't write proper code, Please can anyone provide the solution/suggestions