2024年8月2日解決済み

const n = getRandom(6) + 1; と定義してもよいですか?

ユーザー
function getRandom(max) {
    return Math.floor(Math.random() * max);
  }
  for (let i = 0; i < 10; i++) {
    const n = getRandom(6) + 1;
    console.log(`${i}:${n}`);
  }

max+1 にしなくても反映されたのですが、動画にある例との違いを教えてください。

スタッフ

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?