JSFiddle - React, Tailwind, and code Playground
by Joe Saad
JavaScript
function createPackage(small, big, goal) {
console.log('--',goal / 5)
let used = Math.floor(goal/5 ) >= big ? big : Math.floor(goal/5)
console.log('used large: ',used)
const smpt = goal > used*5 ? goal - used*5 : 0;
const usedsmpt = smpt > small ? -1 : smpt;
console.log('should be used small: ',smpt)
console.log('available small: ',usedsmpt)
}
createPackage(8,3,28);