跳到主要内容

JavaScript

This section includes notes I took when taking the JavaScript tutorial from Scrimba.

  1. document.getElementById("element-id"): gets the element using its ID.

  2. .innerText and textContent: .innerText modifies the element's text (only human-readable content), including HTML tags. textContent modifies the element's text and all its children that are for formatting purposes only.

  3. variable = variable + something equals to variable += something

  4. if ... else statement

    if (sum < 21) {
    console.log()
    } else if (sum === 21){
    console.log("Wohoo! You've got blackjack!")
    } else if (sum > 21){
    console.log("You're out of the game")
    }
    // or
    if (sum < 21) {
    console.log()
    } else if (sum === 21){
    console.log("Wohoo! You've got blackjack!")
    } else (sum > 21){
    console.log("You're out of the game")
    }