# JS Reference Error Assignment to Undeclared Variable

### --- title: "JS ReferenceError -- Assignment to undeclared variable"
错误代码：

\`\`\`js index = game.initialisingPlayers.indexOf(data.id) \`\`\`

正确代码：

\`\`\`js let index = game.initialisingPlayers.indexOf(data.id) \`\`\`

或者使用 const。
