运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Arrays</h2> <p>Compute a new array with the full name of each person in the old array:</p> <p id="demo"></p> <script> const persons = [ {firstname : "Malcom", lastname: "Reynolds"}, {firstname : "Kaylee", lastname: "Frye"}, {firstname : "Jayne", lastname: "Cobb"} ]; document.getElementById("demo").innerHTML = persons.map(getFullName); function getFullName(item) { return [item.firstname,item.lastname].join(" "); } </script> </body> </html>