I am a beginner programmer and am attempting to create a Text Adventure with javascript, however, the text will not show and I couldn't find any obvious errors. could someone plaese help.
js const textElement = document.getElementById('text') const optionButtonsElement = document.getElementById('option-buttons')
let state = {}
function startGame() {
state = {}
showTextNode(1)
}
function showTextNode(textNodeIndex) {
const textNode = textNodes.find(textNode.id === textNodeIndex)
textElement.innerText = textNode.text
while (optionButtonsElement.firstChild) {
optionButtonsElement.removeChild(optionButtonsElement.firstChild)
}
function selectOption(option) {
}
const textNodes = [
{
id: 1,
text: "You wake up in a room you've never seen before. Getting out of bed, you note the silver, almost royal, color scheme of the room.",
option: [
{
text: 'Examine the Room',
setState: { RoomKnowledge: true },
nextText: 2
}
]
}
{
id: 2
}
]
startGame()
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
<link rel="stylesheet" href="style.css">
<script src="game.js"></script>
</head>
<body>
<div class="container">
<div id="text"></div>
<div id="option-buttons" class="btn-grid">
<button class="btn">Option 1</button>
<button class="btn">Option 2</button>
<button class="btn">Option 3</button>
<button class="btn">Option 4</button>
</div>
</div>
</body>
</html>