This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* PROBLEM: Change | |
* You are writing a change calculating algorithm that will | |
* determine the proper change with the smallest possible amount | |
* of coins and bills. | |
* For the problem, consider you have: | |
* - Bills: 100, 50, 20, 10, 5 and 2 | |
* - Coins: 1, 0.5, 0.25, 0.10, 0.05 and 0.01 | |
* | |
* Enough talk... Get coding! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Demonstrating Imprecision | |
*/ | |
let n = 1.22 | |
while (n && n > 0) { | |
let m = n; | |
n = n - 0.01 | |
console.log(`${m} - ${0.01} = ${n}`) |
NewerOlder