- Reflow Wiki text width to 80 characters
- Update Hint 2 for better readability
- Change solution function name to match main repo
- Lint solution, remove extra spaces, change from four spaces to two spaces
-- You have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.
+
+- You have to create a program that will handle when the register does not have
+ enough cash or will have no cash after the transaction. Other than that it
+ needs to return an array of the change in the form of an array, so that will
+ be a 2D array.
##Hint: 1
-- Is easier to handle if you will have to close the register or if you will not have enough money to complete the transaction if you know beforehand how much money is on your register. For this it would be recommended to have a function get the information assigned to a variable.
+
+- It is easier to handle if you have to close the register, or if you know how
+ much money is in your register beforehand and you will not have enough money
+ to complete the transaction. For this it is recommended to have a function to
+ assign this information to a variable.
##Hint: 2
-- Life is easier when you get to know the value of each currency type in the register instead of how much money is composed of that particular currency. So be sure to watch out for that.
+
+- Life is easier when you get to know the value of each currency type in the
+ register instead of how much money is composed of that particular currency.
+ So be sure to watch out for that.
##Hint: 3
-- You will have to get as much change from one type before moving to the next from greater value to lesser, and keep going until you have covered the whole change.
+
+- You will have to get as much change from one type before moving to the next
+ from greater value to lesser, and keep going until you have covered the whole
-// Round change to the nearest hundreth to deal with precision errors
- change =Math.round(change *100) /100;
- }
-// Add this denomination to the output only if any was used.
-if(value >0) {
-acc.push([ curr.name, value ]);
- }
-return acc; // Return the current Change Array
- }, []); // Initial value of empty array for reduce
-
-// If there are no elements in change_arr or we have leftover change, return "Insufficient Funds"
-if(change_arr.length<1|| change >0) {
+return acc; // Return the current Change Array
+ }, []); // Initial value of empty array for reduce
+
+// If there are no elements in change_arr or we have leftover change, return
+// the string "Insufficient Funds"
+if (change_arr.length<1|| change >0) {
return"Insufficient Funds";
}
-
+
// Here is your change, ma'am.
return change_arr;
}
@@ -85,6 +100,9 @@ function drawer(price, cash, cid) {
- Read comments in code.
#Credits:
-If you found this page useful, you can give thanks by copying and pasting this on the main chat: **`thanks @Rafase282 @SaintPeter for your help with Algorithm: Exact Change`**
+If you found this page useful, you can give thanks by copying and pasting this
+on the main chat: **`thanks @Rafase282 @SaintPeter @erictleung for your help
+with Algorithm: Exact Change`**
->**NOTE:** Please add your username only if you have added any **relevant main contents** to the wiki page. (Please don't remove any existing usernames.)
+>**NOTE:** Please add your username only if you have added any **relevant main
+> contents** to the wiki page. (Please don't remove any existing usernames.)
0 comments on commit
f586407