JSFiddle - React, Tailwind, and code Playground

by kplatova

JavaScript

const moneti = [5, 10, 1, 3];
const koshel = 534798;

const getCoins = (wallet, coins) => {
  coins.sort((a,b) => b-a).reduce((acc, curVal, idx, arrCoins) => {
  
  	acc[curVal] = wallet / curVal;
    
	}, {});
}

getCoins(koshel, moneti);