スクリプト内の配列をHTMLで表にしたいのですが、変換できません。どこが間違っていますでしょうか。スクリプト内が全く現れません。
<body> <h1>Mountains</h1> <div id="mountains"></div> <table id="targetTable"> <tr> <th>name</th> <th>height</th> <th>place</th> </tr> </table></script> </body><script> const MOUNTAINS = [ {name: "Kilimanjaro", height: 5895, place: "Tanzania"}, {name: "Everest", height: 8848, place: "Nepal"}, {name: "Mount Fuji", height: 3776, place: "Japan"}, {name: "Vaalserberg", height: 32, place: "Netherlands"}, {name: "Denali", height: 6168, place: "United States"}, {name: "Popocatepetl", height: 5465, place: "Mexico"}, {name: "Mont Blanc", height: 4808, place: "Italy/France"} ]; var table = documnet.getElementById('targetTable'); var newTable; for (let i = 0; i< MOUNTAINS.length; i++){ newTable = document.createElement('targetTable'); newTable.appendChild(document.createTextNode('newTable')); MOUNTAINS[i].appendChild(newTable); }
回答2件
あなたの回答
tips
プレビュー