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.