Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 4/img/avocado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 4/img/basket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 4/img/carrot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 4/img/carrot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions 4/lesson_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Task 1
var num_1 = prompt("please type number from 0 to 999: ")
if (num_1 > 999){
alert("your number " + num_1 + " bigger than 999");
}
else{
var units = num_1 %10
num_1 = Math.floor(num_1 / 10);
if (num_1 >= 1){
var dozens = num_1 %10
num_1 = Math.floor(num_1 / 10);
if(num_1 >= 1){
var hundreds = num_1 %10
alert("hundreds: " + hundreds + "dozens: " + dozens + "units: " + units)
}
else{
alert("dozens: " + dozens + "units: " + units)
}
}
else{
alert("units: " + units)
}
}

//Task 2
let cart = {
"soap": 25 ,
"paint": 35,
"cloth": 200
};




function countBasketPrice(user_cart){
var price = 0;
for(var i in user_cart){
price = price + user_cart[i];
}
return(price);
}

alert(countBasketPrice(cart))





22 changes: 22 additions & 0 deletions 4/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.cart {
background: url(img/basket.png);
margin: 300px auto;
height: 157px;
width: 150px;

}

.carrot{
background: url(img/carrot.jpg);
margin: 200px auto;
height: 250px;
width: 300px;
}

.avocado{
background: url(img/avocado.png);
margin-top: 100px;
margin-left: 240px;
height: 250px;
width: 300px;
}
15 changes: 15 additions & 0 deletions 4/tests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet" href="styles.css">
<script src="lesson_4.js"></script>
<body>
<div class="cart"></div>
<div class="carrot"></div>
<div class="avocado"></div>

</body>
</html>