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 modified .DS_Store
Binary file not shown.
Binary file added lesson2/.DS_Store
Binary file not shown.
Binary file added lesson3/.DS_Store
Binary file not shown.
Binary file added lesson4/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions lesson4/HW4/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lesson4/HW4/.idea/HW4.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lesson4/HW4/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lesson4/HW4/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lesson4/HW4/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions lesson4/HW4/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Task 1

function numToObj(num) {
objNum.init(num);
return objNum;
}

const objNum = {

['единицы']: 0,
['десятки']: 0,
['сотни']: 0,

init(num){
this.сотни = Math.floor(num / 100);
num %= 100;
this.десятки = Math.floor(num / 10);
num %= 10;
this.единицы = num;
}
}

let userNum = parseInt(prompt());
if (userNum > 999) {console.log('плохое число', objNum)};

console.log(numToObj(userNum));

// Task 2

const item1 = {
name: 'cup',
price: 20,
quantity: 2
}

const item2 = {
name: 'plate',
price: 40,
quantity: 4
}

const basket = {
contents: [],

addToBasket(item) {
this.contents.push(item);
},

calculateTotal() {
let total = 0
for (let i = 0; i < this.contents.length; i++) {
total += this.contents[i].price * this.contents[i].quantity;
}
return total;
}
}

basket.addToBasket(item1);
basket.addToBasket(item2);
console.log(basket.calculateTotal())