Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function renovation(input) {
- let hights = Number(input[0]);
- let wide = Number(input[1]);
- let noPaintPercent = Number(input[2]);
- let index = 3
- let littersPaintForCurrentDay = input[index];
- let noPaintDecimal = noPaintPercent / 100
- let allArea = hights * wide * 4;
- let allPaintArea = Math.floor(allArea - (allArea * noPaintDecimal))
- while (littersPaintForCurrentDay !== "Tired!") {
- littersPaintForCurrentDay = Number(input[index]);
- allPaintArea -= littersPaintForCurrentDay
- if (allPaintArea > 0) {
- index++
- littersPaintForCurrentDay = input[index];
- } if (allPaintArea < 0) {
- console.log(`All walls are painted and you have ${Math.abs(allPaintArea)} l paint left!`); return;
- }
- else if (allPaintArea === 0) {
- console.log("All walls are painted! Great job, Pesho!"); return;
- }
- }
- console.log(`${allPaintArea} quadratic m left.`);
- }
- //renovation(["3","5","10","2","3","4","Tired!"]);
- renovation(["2", "3", "25", "6", "7", "5"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement