-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatatypes.js
More file actions
81 lines (64 loc) · 1.36 KB
/
Copy pathdatatypes.js
File metadata and controls
81 lines (64 loc) · 1.36 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// const person = {
// name: "John",
// age: 25,
// isDropout: true,
// address: {
// street: "123 Main St",
// city: "Anytown",
// country: "USA"
// }
// };
// person.name = "kryssie";
// console.log(person);
// var car = {
// name: "cyber truck",
// name: "benz",
// color: "black",
// year: 2022,
// owner: null,
// others:{
// isRegistered: true,
// mileage: `${10000} km`
// }
// }
// let car1 = {...car};
// console.log('car1:', car1);
// console.log('car:', car);
let walletSystem = {
users: {
alice: {
balance: 1000,
transactions: [100, 200]
},
bob: {
balance: 2000,
transactions: [500, 300]
}
},
currency: "NGN",
isActive: true
};
/*
Step 1 — Update Balances
Create a new object updatedWalletSystem using spread
Add 500 to Alice’s balance
Add 1000 to Bob’s balance
Append these amounts to their transactions array
Step 2 — Add New User
Add a new user charlie with:
balance: 1500
transactions: [1500]
Step 3 — Change Currency & Add Settings
Change currency → "USD"
Add a nested object settings:
settings: {
theme: "dark",
notifications: true
}
*/
updatedWalletSystem = {
...walletSystem,
users: {
...walletSystem.users,
}
}