forked from gabischool/Week5_JS_Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.js
106 lines (78 loc) · 2.47 KB
/
objects.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
Task 1: Gamer Profile Manager 🎮 🎮 🎮 🎮
You are creating a system to manage a gamer's profile.
Steps:
1. Create an object named `gamerProfile` with the following properties:
- `username` (string): The gamer's username.
- `level` (number): The gamer's level.
- `isOnline` (boolean): Whether the gamer is currently online.
2. Write a function `updateOnlineStatus` that:
- Takes the `gamerProfile` object and a boolean `status` as arguments.
- Updates the `isOnline` property based on the `status`.
- Logs: "[username] is now online." or "[username] is now offline."
Example:
Input:
const gamerProfile = {
username: "ShadowSlayer",
level: 5,
isOnline: false
};
updateOnlineStatus(gamerProfile, true);
Expected Output:
"ShadowSlayer is now online."
*/
// ✍️ Solve it here ✍️
/*
Task 2: Dress Inventory Checker 👗 👗 👗 👗 👗
You are helping a fashion designer manage their dress inventory.
Steps:
1. Create an object named `dress` with the following properties:
- `name` (string): Name of the dress.
- `size` (string): Size of the dress.
- `inStock` (boolean): Whether the dress is available.
2. Write a function `checkAvailability` that:
- Takes the `dress` object as an argument.
- Logs: "[name] is available in size [size]." if the dress is in stock.
- Logs: "[name] is out of stock." if the dress is not available.
Example:
Input:
const dress = {
name: "Evening Gown",
size: "M",
inStock: true
};
checkAvailability(dress);
Expected Output:
"Evening Gown is available in size M."
*/
// ✍️ Solve it here ✍️
/*
Task 3: Supercar Feature Adder 🚗 🚗 🚗 🚗
You are building a configurator for a supercar.
Steps:
1. Create an object named `supercar` with the following properties:
- `model` (string): The car's model.
- `price` (number): The base price.
- `features` (object): An object with a `color` property.
2. Write a function `addFeature` that:
- Takes the `supercar` object and a feature name (string) as arguments.
- Adds the feature to the `features` object and sets it to `true`.
- Logs: "[featureName] has been added to [model]."
3. Use a **for...in loop** to log all the features of the `supercar` object.
Example:
Input:
const supercar = {
model: "Ferrari SF90",
price: 500000,
features: {
color: "Red"
}
};
addFeature(supercar, "turbo");
Expected Output:
"Turbo has been added to Ferrari SF90."
Features:
- color: Red
- turbo: true
*/
// ✍️ Solve it here ✍️