

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Objects
incomplete
2: No Colon
incomplete
3: Updating Properties
incomplete
4: Nesting Properties
incomplete
5: Nesting Properties Quiz
incomplete
6: Optional Chaining
incomplete
7: When to Chain
incomplete
8: Object Methods
incomplete
9: Methods Mutate
incomplete
10: Initializing Props
incomplete
11: Strings As Keys
incomplete
12: This
incomplete
13: Arrow Functions
incomplete
14: Fat Arrows and This
incomplete
15: Spread Syntax
incomplete
16: Return Objects
incomplete
17: Destructuring
incomplete
18: Not Bound
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
JavaScript has a really nifty spread syntax for moving groups of object properties around. It's a great way to copy objects and merge object properties.
const engineering_dept = {
lane: "grand magus",
hunter: "software engineer",
allan: "software engineer",
matt: "software engineer",
dan: "software engineer",
waseem: "software engineer",
};
const video_dept = {
stass: "video producer",
alex: "video producer",
};
const all_employees = { ...engineering_dept, ...video_dept };
/*
{
lane: 'grand magus',
hunter: 'software engineer',
allan: 'software engineer',
matt: 'software engineer',
dan: 'software engineer',
waseem: 'software engineer',
stass: 'video producer',
alex: 'video producer'
}
*/
The spread syntax shallow-copies the properties of the objects you're spreading. If properties have the same name, the last (right-most) object's property will overwrite the previous ones.
const engineering_dept = {
lane: "software engineer",
hunter: "software engineer",
};
const video_dept = {
lane: "cringe youtuber",
alex: "video producer",
};
const all_employees = { ...engineering_dept, ...video_dept };
/*
{
lane: 'cringe youtuber',
hunter: 'software engineer',
alex: 'video producer'
}
*/
Textio allows you to generate messages based on templates. You can pick from the given default templates or create your own.
Complete the mergeTemplates function. It takes an object defaultTemplates and an object customTemplates and returns a merged object with the custom templates overwriting the default templates.