Floats Operations Imprecision
Welcome to Bank Ruptcy, and we want to hire you to fix our algorithm to exchange the stock options, because we have some weird behaviour.
This is our algorithm to exchange the stock options:
var stockOptionsCost = 10.70, paid = 20.80;
function calculateChange() {
return paid - stockOptionsCost;
}
function calculateAmountOfStockOptions () {
return paid / stockOptionsCost;
}
var amountStockOptions = calculateAmountOfStockOptions();
var yourChange = calculateChange();What returns calculateAmountOfStockOptions ?
1.94392523364486__match_answer_and_solution__What is the value of calculateChange ? Input the number value.
Why?
Please fix this code to return the correct change.
Last updated
Was this helpful?