I made a little program to find minimum number of notes(currency) for the required amount. for example, let's say I enter an amount 1121 and I have an array of these values below: notes = [1, 2, 5, 10, 50, 100, 200, 500] so my final result will be:
500 * 2(notes) = 1000
100 * 1 = 100
20 * 1 = 20
1 * 1 = 1
then the total would be 1121. any help with understanding would be much appreciated. I know it only takes one for loop but I'm confused in some parts.
here's what I did: https://stackblitz.com/edit/angular-rufwzk?file=src%2Fapp%2Fapp.component.ts