以下のプログラムの間違っている点を修正してください。
let taipu = ["mizu", "honoo", "kusa"];
let i = Math.floor(Math.random() * 3)
if (taipu[i] == mizu) {
console.log("水が選ばれたよ。")
}
以下のプログラムの間違っている点を修正してください。
<body>
<div id="x"></div>
</body>
for (let i = 0; i < 5; i++) {
let text = document.createElement("p");
text.textContent = "こんにちは。(" + i + "回目)";
x.appendChild(text);
}
以下のプログラムの間違っている点を修正してください。
let waza = [{name: "hinoko", damage: 20},
{name: "mizudeppo", damage: 15}
];
for (let i = 0; i < 2; i++) {
let x = waza[i].name;
}
console.log("2つめの技の名前", x[1]);
以下のプログラムの間違っている点を修正してください。
<body>
<button id="button1"></button>
</body>
function logTime() {
console.log(new Date());
}
let button1 = document.getElementById("button1");
button1.addEventListener("click", logTime());
以下のプログラムの間違っている点を修正してください。
<body>
<button id="button2"></button>
</body>
let button2 = document.getElementById("button2")
button2.addEventListener("click",
let x = prompt("入力してね");
console.log("入力された値: ", x);
);
以下のプログラムの間違っている点を修正してください。
<body>
<div id="y"></div>
</body>
function createButton() {
let x = document.createElement("button");
x.style.backgroundColor = "rgb(255, 0, 0)";
document.getElementById("y").appendChild(x);
return x;
}
createButton.addEventListener("click", function () { console.log("おされたよ"); });
以下のプログラムの間違っている点を修正してください。
<body>
<div id="z"></div>
</body>
let memo = ["", "", "", "", ""];
function createButton() {
let x = document.createElement("button");
x.style.backgroundColor = "rgb(255, 0, 0)";
document.getElementById("z").appendChild(x);
return x;
}
for (let i = 0; i < 5; i++) {
let button = createButton();
let value = prompt("入力してね。");
button.addEventListener("click", function () { memo[i] = value; });
console.log("メモの内容", memo[i]);
}