Question: Write and test a function named getDollarAmt that accepts a string in currency format, and returns a number representing the value. For this function, you
Write and test a function named getDollarAmt that accepts a string in currency format, and returns a number representing the value. For this function, you must use a for loop that processes the string.?
?
Examples:?
?
getDollarAmt('$120.00') => 120?
getDollarAmt("$23.98") => 23.98?
typeof(getDollarAmt('$1.00')) => number?
Please do not give me this code
function getDollarAmt(s){
return parseFloat(s.substr(1,s.length));
}
Need the code that use a for loop that processes the string.
Step by Step Solution
3.40 Rating (163 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
635d866b84200_176434.pdf
180 KBs PDF File
635d866b84200_176434.docx
120 KBs Word File
