-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.js
64 lines (47 loc) · 864 Bytes
/
tasks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// JavaScript.info tasks
// task 1
let user = {};
user.name = "John";
user.surname = "Smith";
user.name = "Peter";
delete user.name;
// Task 2
const isEmpty = (obj) => {
for (let key in obj){
return false;
}
return true;
}
let schedule = {};
console.log(isEmpty(schedule))
schedule["8:30"] = "get up";
console.log(isEmpty(schedule))
// task 3
let salaries = {
John: 100,
Ann: 160,
Pete: 130
}
function checkSum(obj) {
let sum = 0;
for (let keys in obj) {
sum += obj[keys];
}
return sum;
}
console.log(checkSum(salaries))
// task 4
const multiplyNumeric = (obj) => {
for (let key in obj) {
if (typeof obj[key] == 'number') {
obj[key] *= 2;
}
}
}
let menu = {
width: 200,
height: 300,
title: "My menu"
};
multiplyNumeric(menu)
console.log(menu)