[JavaScript Fundamentals] Pipes In Pool
Здравейте, всички! Имам проблем с една от изпитните задачки. За зла участ не виждам изхода на повечето тестове. Задачата е тази
Някакви идеи къде греша?
function pipesInPool([arg1, arg2, arg3, arg4]) {
let capacity = Number(arg1)
let pipe1 = Number(arg2)
let pipe2 = Number(arg3)
let time = Number(arg4)
let isOverflow = ((pipe1 * time) + (pipe2 * time))
let percentFull = ((isOverflow / capacity) * 100)
let p1ToPercent = Math.trunc((pipe1 * time / isOverflow) * 100)
let p2ToPercent = Math.trunc((pipe2 * time / isOverflow) * 100)
let diffFullOver = (isOverflow - capacity).toFixed(1)
if (isOverflow < capacity) {
console.log("The pool is " + percentFull + "% full. Pipe 1: " + p1ToPercent + "%. Pipe 2: " + p2ToPercent + "%.")
} else if (isOverflow > capacity) {
console.log("For " + time + " hours the pool overflows with " + diffFullOver + " liters.")
}
}
pipesInPool([1000, 500, 120, 3])