Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = ['1.92', '5'];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- let price = +gets();
- let paid = +gets();
- let change = (paid - price) * 100;
- if (change > 100) {
- const levCount = ~~(change / 100);
- change -= levCount * 100;
- print(`${levCount} x 1 lev`);
- }
- if (change > 50) {
- change -= 50;
- print(`1 x 50 stotinki`);
- }
- if (change > 20) {
- const stotinkiCount = ~~(change / 20);
- change -= 20 * stotinkiCount;
- print(`${stotinkiCount} x 20 stotinki`);
- }
- if (change > 10) {
- change -= 10;
- print(`1 x 10 stotinki`);
- }
- if (change > 5) {
- change -= 5;
- print(`1 x 5 stotinki`);
- }
- if (change > 2) {
- const stotinkiCount = ~~(change / 2);
- change -= 2 * stotinkiCount;
- print(`${stotinkiCount} x 2 stotinki`);
- }
- if (change === 1) {
- print(`1 x 1 stotinka`);
- }
Advertisement
Add Comment
Please, Sign In to add comment