Challenge: Combine Objects with the Spread Operator
Task
Create a script that performs the following tasks:
- Merge the properties of two objects,
personInfo
andjobInfo
, and store them in a new object namedfullInfo
. - Add a new property to the
fullInfo
object namedisRetired
with a value offalse
. - Use a
for...in
loop to iterate throughfullInfo
, and log each property and its corresponding value in the format:[property]: [value]
.
const personInfo = { name: "Ferry", age: 62, city: "Caracas", }; const jobInfo = { experience: 7, occupation: "Speech-Language Pathologist", }; // Task 1: merge two objects const fullInfo = { ...___, ___, ___: ___, // Task 2: add the property }; // Task 3: log each property and its value for (let key in ___) { console.log(`${___}:`, ___[key]); }
Expected output:
pythonname: Ferryage: 62city: Caracasexperience: 7occupation: Speech-Language PathologistisRetired: false
Takk for tilbakemeldingene dine!