-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfp4.js
33 lines (22 loc) · 773 Bytes
/
fp4.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
const meal = {
description: 'Dinner',
};
// 1. In an Immutable way, add a property to the
// meal called calories setting it's value to 200,
// then log the result to the console
const mealWithCalories = {
...meal,
calories: 200
};
console.log(mealWithCalories)
// 2. In an Immutable way, increase the calories
// by 100 and print the result to the console
const mealWithMoreCalories = {
...mealWithCalories,
calories: mealWithCalories.calories + 100
};
console.log(mealWithMoreCalories)
// 3. In an Immutable way, remove the calories property and log the result to the console
const { calories, ...mealWithoutCalories } = mealWithMoreCalories;
console.log(mealWithoutCalories, calories)
// See solution at: https://jsbin.com/sunewil/edit?js,console