Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 791 Bytes

对象取值.md

File metadata and controls

56 lines (40 loc) · 791 Bytes

lesson1 对象取值

题目

有一个 person 对象,person 对象含有属性 firstNamelastNameage,如:

var person = {
  firstName: 'Bill',
  lastName: 'Gates',
  age: 56,
}

请书写一个 print 函数,函数参数为 person 对象,该函数按照如下格式进行打印:

{firstName} {lastName}'s age is {age}

例如: 参数 person 对象为:

var person = {
  firstName: 'Bill',
  lastName: 'Gates',
  age: 56,
}

打印结果应该为: Bill Gates's age is 56

答题

function print(person) {
  // write your code here...
}

var bill = {
  firstName: 'Bill',
  lastName: 'Gates',
  age: 56,
};

print(bill); // 打印 Bill Gates's age is 56

知识点

对象取值

字符串拼接

打印