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
21 changes: 21 additions & 0 deletions HW3_2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
'use strict';
for (let i = 0; i <= 10; i++) {
if (i % 2 == 0 && i != 0) {
console.log(`${i} - четное число`)
} else if (i != 0) {
console.log(`${i} - нечетное число`)
} else {
console.log(`${i} - это ноль`)
}
}
</script>
</body>
</html>
41 changes: 41 additions & 0 deletions HW3_3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
'use strict';
const post = {
author: "John", //вывести этот текст
postId: 23,
comments: [
{
userId: 10,
userName: "Alex",
text: "lorem ipsum",
rating: {
likes: 10,
dislikes: 2 //вывести это число
}
},
{
userId: 5, //вывести это число
userName: "Jane",
text: "lorem ipsum 2", //вывести этот текст
rating: {
likes: 3,
dislikes: 1
}
},
]
}

console.log(post.author);
console.log(post.comments[0].rating.dislikes);
console.log(post.comments[1].userId);
console.log(post.comments[1].text);
</script>
</body>
</html>
35 changes: 35 additions & 0 deletions HW3_4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
'use strict';
const products = [
{
id: 3,
price: 200,
},
{
id: 4,
price: 900,
},
{
id: 1,
price: 1000,
},
];

let discount = 0.15;

const sale = function(item) {
item.sale_price = item.price * (1 - discount)
}

products.forEach(sale);
console.log(products);
</script>
</body>
</html>
44 changes: 44 additions & 0 deletions HW3_5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
'use strict';
const products = [
{
id: 3,
price: 127,
photos: [
"1.jpg",
"2.jpg",
]
},
{
id: 5,
price: 499,
photos: []
},
{
id: 10,
price: 26,
photos: [
"3.jpg"
]
},
{
id: 8,
price: 78,
},
];

let hasPicture = products.filter(function(product) {
return product.hasOwnProperty("photos") && product.photos[0] != undefined
});

console.log(hasPicture);
</script>
</body>
</html>
15 changes: 15 additions & 0 deletions HW3_6.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
'use strict';

for (let i = 0;; i < 10; console.log(i++)) {
}
</script>
</body>
</html>
19 changes: 19 additions & 0 deletions HW3_7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
'use strict'

let hill = "";

for (let i = 1; i <= 20; i++) {
hill = hill + "x";
console.log(hill)
}
</script>
</body>
</html>