// If given "George", "Washington" as arguments, it should return "Washington, George"
function formatName(firstName, lastName) {
return [lastName, firstName];
}
请参阅链接。我无法弄清楚如何在名字和姓氏之间加上一个简单的空格。我已经在这几个小时请帮助!
答案 0 :(得分:0)
使用字符串连接
return lastName +', '+ firstName;
function formatName(firstName, lastName) {
return lastName +', '+ firstName;
}
console.log(formatName("George","Washington"))

如果你的任务真的要处理给定的数组而不是使用带有所需分隔符的Array.prototype.join()
method 参数', '
function formatName(firstName, lastName) {
return [lastName, firstName].join(', ');
}
console.log(formatName("George","Washington"))

答案 1 :(得分:0)
您应该返回一个连接名字和姓氏的字符串。试试这个:
return lastName +", "+ firstName;
答案 2 :(得分:0)
尝试使用join(', ')
function formatName(firstName, lastName) {
return [lastName, firstName].join(', ');
}