Created
June 13, 2018 16:35
-
-
Save UlvacMoscow/0fb57fb8cfc414f36bbbd4c7f7e0c8da to your computer and use it in GitHub Desktop.
Homework 1.5 created by Ulvac - https://repl.it/@Ulvac/Homework-15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
// 1 | |
var price; | |
var taxes = 0; | |
function update_taxes(offerPrice) { | |
let taxe = 0.73 * offerPrice; | |
taxes += taxe; | |
return console.log(`Налог с продажи 73 % к оплате ${taxes} Q`) | |
}; | |
update_taxes(100); | |
update_taxes(200); | |
update_taxes(300); | |
// 2 | |
var wrappingPaper = 30 ; | |
function packaging(a, b, c) { | |
let area_box = 2 * (a * b + b * c + a * c); | |
wrappingPaper -= area_box; | |
if (wrappingPaper >= 0) { | |
return console.log(`Заказ ${a, b, c} упакован, осталось упаковочной бумаги ${wrappingPaper} м2`) | |
} | |
else { | |
return console.log(`Заказ ${a, b, c} не упакован, осталось упаковочной бумаги ${wrappingPaper} м2`) | |
} | |
}; | |
packaging(1, 1, 1); | |
packaging(2, 2, 2); | |
packaging(5, 5, 5); | |
// 3 | |
var chargeTeleport = [7, 2, 1, 4, 8]; | |
var chargeInfo = [use_teleport(0), use_teleport(0), use_teleport(2), use_teleport(2)]; | |
function use_teleport(teleport) { | |
if (chargeTeleport[teleport] === 0) { | |
return console.log(`Телепорт ${teleport + 1} недоступен, заряжаеться`) | |
} | |
chargeTeleport[teleport]--; | |
if (chargeTeleport[teleport] === 0) { | |
return console.log(`Телепорт ${teleport + 1} использован, заряд - ${chargeTeleport[teleport]}, требуеться подзарядка`) | |
} | |
return console.log(`Телепорт ${teleport + 1} использован, заряд — ${chargeTeleport[teleport]} единиц`); | |
}; | |
function check_charge() { | |
for (let num = 0; num < chargeTeleport.length; num++) { | |
console.log(`Телепорт ${num + 1}, заряд — ${chargeTeleport[num]} единиц`) | |
}; | |
}; | |
check_charge(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
homework 1.5