function iWantToGet(ammountRequired) {
const avaibleNotes = [50, 25, 10, 5, 1];
const result = [];
if (ammountRequired > 0) {
for (let i = 0; i < avaibleNotes.length; i++) {
let note = avaibleNotes[i];
while (ammountRequired - note >= 0) {
ammountRequired -= note;
result.push(note);
}
}
} else {
console.log('Please enter new amount');
}
return result;
}
console.log(iWantToGet(100));