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
20 changes: 20 additions & 0 deletions 1/chess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function drawBoard() {
let board = document.querySelector('.board')
let block
let flag = true
for (let i = 0; i < 8; i++) {
for (let j = 0; j < 8; j++) {
if (j == 0) flag = !flag;
block = document.createElement('div')
if (flag) {
block.classList = 'block black'
} else {
block.classList = 'block white'
}
board.appendChild(block);
flag = !flag;
}
}
}

drawBoard()
14 changes: 14 additions & 0 deletions 1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>Шахматная доска</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div class="board"></div>
<script src="chess.js"></script>
</body>

</html>
20 changes: 20 additions & 0 deletions 1/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.board {
height: 640px;
width: 640px;
margin: 30px auto;
border: 1px solid black;
}

.block {
height: 80px;
width: 80px;
float: left;
}

.black {
background: black;
}

.white {
background: white;
}
13 changes: 13 additions & 0 deletions 2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>Корзина</title>
</head>
Comment on lines +4 to +6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

забыли использовать этот тег, иначе у меня выводилось не корзина пуста, а какие-то каракули)

<meta charset="UTF-8">


<body>
<div>#test</div>
<script src="soruse.js"></script>
</body>

</html>
31 changes: 31 additions & 0 deletions 2/soruse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var basket = {
summ: 0,
items: [],
append: function (item) { this.items.push(item) },
get_size: function () { return this.items.length },
get_items: function () { return this.items },
all_cost: function () {

for (var i in this.items) {
if (i != undefined) { this.summ += this.items[i].cost }
}
Comment on lines +9 to +11
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все отлично, но лучше использовать reduce, поскольку при трудоустройстве часто смотрят умеет ли кандидат использовать методы для работы с массивами или везде использует for

if (this.summ == 0) {
return 'корзина пуста'
} else{
return this.summ
}

}

}

// var it = { name: 'Пицца', cost: 150 }
// var it2 = { name: 'Машина', cost: 1500 }
// basket.append(it)
// basket.append(it2)

function drawBoard() {
alert(basket.all_cost())
}

drawBoard()