執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到 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>