I don't know how to think about a question. Since I know the people here are much more experienced and guiding, I would like to ask you. I'd appreciate it if you could solve the problem and explain it. Question:
"Think that you have an unlimited number of carrots, but limited number of carrot types. Also, you have one bag that can hold a limited weight. Each type of carrot has a weight and a price. Write a function that takes carrotTypes and capacity and return the maximum value the bag can hold."
I'm not sure I fully understand the question and understand how I can do it. I'd be very happy if you could help me.
let carrotTypes = [{
price: 100,
kg: 2
},
{
price: 120,
kg: 4
},
{
price: 80,
kg: 7
}
];
let bagCapacity = 36; //kg
getMaxValue(carrotTypes, bagCapacity)
function getMaxValue(carrotTypes, capacity) {
carrotTypes.forEach(carrot => {
console.log(carrot);
});
}