-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblems.js
More file actions
51 lines (43 loc) · 889 Bytes
/
Copy pathproblems.js
File metadata and controls
51 lines (43 loc) · 889 Bytes
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
let user = {};
user.name = "John";
user["surname"] = "Smith";
console.log(user);
user.name = "Pete";
console.log(user);
delete user.name;
console.log(user);
// Check for object emptiness
const isEmpty = (object) => {
for (let key in object) {
return false;
}
return true;
};
//Sum of properties value
const salaries = {
Ram: 200,
Shyam: 300,
Jadu: 500,
};
let sum = 0;
for (let key in salaries) {
sum = sum + salaries[key];
}
console.log(`Sum of Salaries: ${sum}`);
// Create a function multiplyNumeric(obj) that multiplies all numeric property values of obj by 2.
// before the call
let menu = {
width: 200,
height: 300,
title: "My menu",
};
const myFunc = (object) => {
for (let key in object) {
let type = typeof object[key];
if (type == "number") {
object[key] = object[key] * 2;
}
}
return object;
};
console.log(myFunc(menu));