scrimba
Learn JavaScript loops and iteration
🔁 Test your skills with this game!
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

🔁 Test your skills with this game!
AboutCommentsNotes
🔁 Test your skills with this game!
Expand for more info
index.js
run
preview
console
import challengeData from "./challengeData"

// Page elements
const page = document.getElementsByTagName("body")
const headingMain = document.getElementsByTagName("h1")[0]
const challengeBlurb = document.getElementById("challengeText")
const challengeImg = document.getElementsByClassName("challenge_img")[0]
const prevBtn = document.getElementById("prevBtn")
const nextBtn = document.getElementById("nextBtn")
const lessonLink = document.getElementById("lessonLink")

// Challenge ID
const thisID = Number(document.getElementsByTagName("html")[0].id)
const thisIndex = thisID - 1

// Previous / Next links
if (thisID === 1) {
prevBtn.href = ``
prevBtn.classList.add("disabled")
} else {
prevBtn.href = "/" + challengeData[thisIndex - 1].directory + "/index.html"
}
if (thisID === 6) {
nextBtn.href = ``
nextBtn.classList.add("disabled")
} else {
nextBtn.href = "/" + challengeData[thisIndex + 1].directory + "/index.html"
}



// Set all the Challenge-specific content
// Main heading
// Challenge description
// Solution image
// Scrim links

/* Write your solution code inside index.js in the corresponding folder */


Console
/1_for/index.html
-4:13