根据这些数据:
const employees = {
employee1: {name: "Susana", age: 54},
employee2: {name: "Mariano", age: 55}
}
const companies = {
company1: {name: "General Electric"},
company2: {name: "Apple Computers"}
};
我需要创建一个看起来像这样的句子:
Susana works at General Electric
由于两个对象都使用值name
(并且我不允许更改它们),因此我没有想法如何连接它们以创建一个连贯的句子。我该怎么办?
答案 0 :(得分:0)
const createSentence = function (name, company) {
let nombre = employees.employee1['name'];
let compania = companies.company1['name'];
return console.log(nombre + " works at " + compania);
}
createSentence(); // "Susana works at General Electric"