eaweb
asked on
replace   text in javascript
hi,
i using below code to format numbers
roundNumber(formatNumbers( $number, 3), 2).toFixed(2);
the issue is that the $number can come as which is breaking the script. how must i rewrite the code to to check if the $number contains the text and if yes change it to 000 else use the value of $number?
i using below code to format numbers
roundNumber(formatNumbers(
the issue is that the $number can come as which is breaking the script. how must i rewrite the code to to check if the $number contains the text and if yes change it to 000 else use the value of $number?
roundNumber(formatNumbers( $number.replace(/ /g,""), 3), 2).toFixed(2);
ASKER
when running the code i can get it as follow.
roundNumber(formatNumbers( 1616161, 3), 2).toFixed(2); --- ok
or
roundNumber(formatNumbers( , 3), 2).toFixed(2); ---bad
roundNumber(formatNumbers(
or
roundNumber(formatNumbers(
we remove each time
ASKER
this how i get it
roundNumber(formatNumbers( 100000000. replace(/& nbsp;/g,"" ), 3), 2).toFixed(2);
roundNumber(formatNumbers( .rep lace(/&nbs p;/g,""), 3), 2).toFixed(2);
roundNumber(formatNumbers(
roundNumber(formatNumbers(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it would be better(?) to put the "replace" inside your formatNumber function