Debugging

Debugging is the process of finding and fixing errors in code. The challenges below require you to find the errors in the code.

Challenge 1

Reward: 1 point
Why doesn't clicking the button show a story?

HTML

<button id="showStoryButton">Show story</button>
<p id="storyParagraph"></p>

JavaScript

let storyButton = document.getElementById(`storyButton`)
let storyParagraph = document.getElementById(`storyParagraph`)

storyButton.addEventListener(`click`, showStory)

function showStory() {
  storyParagraph.innerHTML = `The dog jumped over the fence.`
}

Reason

Why doesn't clicking the button show a story?

HTML

<button id="storyButton">Show story</button>
<p id="storyParagraph"></p>

JavaScript

let storyButton = document.getElementById(`storyButton`)
let storyParagraph = document.getElementById(`storyParagraph`)

storyButton.addEventListener(`click`, showStory)

function showStory() {
  showStoryParagraph.innerHTML = `The dog jumped over the fence.`
}

Reason

Why doesn't clicking the button show a story?

HTML

<button id="storyButton">Show story</button>
<p id="storyParagraph"></p>

JavaScript

let storyButton = document.getElementById(`storyButton`)
let storyParagraph = document.getElementById(`storyParagraph`)

function showStory() {
  storyParagraph.innerHTML = `The dog jumped over the fence.`
}

Reason

Why doesn't clicking the button show a story?

HTML

<button id="storyButton">Show story</button>
<p id="storyParagraph"></p>

JavaScript

let storyButton = document.getElementById(`storyButton`)
let storyParagraph = document.getElementById(`storyParagraph`)

storyButton.addEventListener(`click`, showStory)

function tellStory() {
  storyParagraph.innerHTML = `The dog jumped over the fence.`
}

Reason

Why doesn't clicking the button show a story?

HTML

<button id="showStory">Show story</button>
<p id="storyParagraph"></p>

JavaScript

let showStory = document.getElementById(`showStory`)
let storyParagraph = document.getElementById(`storyParagraph`)

showStory.addEventListener(`click`, showStory)

function showStory() {
  storyParagraph.innerHTML = `The dog jumped over the fence.`
}

Reason

Next challenge