I am facing a challenge in my JavaScript code. I have an integer that represents the quantity of an order, and there is an object containing all the quantities offered with their respective prices:
{
"1": {
"quantity": 1,
"price": 10
},
"2": {
"quantity": 2,
"price": 20
},
"6": {
"quantity": 6,
"price": 50
},
"12": {
"quantity": 12,
"price": 80
}
}
The task at hand is to identify the object with a quantity value greater than the order quantity, but smaller than the quantity value of the next object in the sequence.
For instance, if the order quantity is 8, it should pick:
"6": {
"quantity": 6,
"price": 50
},
This information is crucial for determining the correct price. Even though I have experimented with multiple LoDash methods, none seem to provide the desired outcome. Is there a solution or approach that can help me achieve this?