04. Food for Pets JS въпрос и помощ
Здравейте, Judge ми дава 66/100 точки.
Във VS Code всичко работи.
Може ли да Ви помоля някой да ми каже къде бъркам?
function petFood(input) {
//let index = 0;
let days = Number(input.shift());
let totalFood = Number(input.shift());
let dogFood = 0;
let catFood = 0;
let counterDog = 0;
let catCounter = 0;
let bonus = 0;
//let command = Number(input[index++]);
for (let i = 1; i <= days; i++) {
let Dogsfood = Number(input.shift());
dogFood += Dogsfood;
counterDog++;
let Catsfood = Number(input.shift());
catFood += Catsfood;
catCounter++;
if (counterDog === 3 && catCounter === 3) {
bonus += (Dogsfood + Catsfood) * 0.1;
bonus = Math.round(bonus);
//console.log(bonus);
}
}
console.log(`Total eaten biscuits: ${bonus}gr.`);
console.log(`${(((dogFood + catFood) / totalFood)* 100).toFixed(2)}% of the food has been eaten.`);
console.log(`${((dogFood / (dogFood+ catFood)) * 100).toFixed(2)}% eaten from the dog.`);
console.log(`${((catFood / (dogFood+catFood)) *100).toFixed(2)}% eaten from the cat.`);
}
Мерси за бързия отговор.