Open Danbaba1 opened 2 years ago
@Danbaba1 I've seen it. Sorry I haven't been able to take a look at it for now, I have a deadline to meet at work. I will check it out for you tomorrow (afternoon or evening).
okay ma thank you.
On Tue, 7 Jun 2022 at 19:38, Obiagba Mary Ifeoma @.***> wrote:
@Danbaba1 https://github.com/Danbaba1 I've seen it. Sorry I haven't been able to take a look at it for now, I have a deadline to meet at work. I will check it out for you tomorrow (afternoon or evening).
— Reply to this email directly, view it on GitHub https://github.com/Ifycode-support/Danbaba1-exercism-issues/pull/4#issuecomment-1149032961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXRP57QEIP7MDLPARUDDTALVN6JKXANCNFSM5YCITGBA . You are receiving this because you were mentioned.Message ID: @.***>
Or better still @Danbaba1 , reuse the time to mix function (i.e function 1) inside function 3 in this manner:
Where function 1 assigns the time to the juices:
export function timeToMixJuice(name) {
let time = 0;
switch(name) {
case 'Pure Strawberry Joy':
time = 0.5;
break;
case 'Energizer':
time = 1.5;
break;
case 'Green Garden':
time = 1.5;
break;
case 'Tropical Island':
time = 3;
break;
case 'All or Nothing':
time = 5;
break;
default:
time = 2.5;
}
return time;
}
And function 3 just calls it when it needs the time:
export function remainingOrders(timeLeft, orders) {
let totalTime = 0;
let index = 0;
while(index < orders.length) {
let time = timeToMixJuice(orders[index]);
totalTime += time;
if (totalTime - timeLeft >= 0) {
orders.splice(0, index + 1);
break;
}
index += 1;
}
if (totalTime < timeLeft) orders = [];
return orders;
}
This validates my point when I said you should just assign inside the switch statement and not attempt to increment inside there.
Attempt at function 3 on mixed juices Exercise.