Skip to main content

Task 30: Javascript Practise - Rinse and Repeat

Affirmations for Confidence and Growth​

  • I am capable of learning anything I set my mind to.

  • I choose progress over perfection every day.

  • I have everything I need to succeed within me.

  • I am focused, consistent, and committed to my goals.

  • I believe in my ability to create positive change.

  • I welcome challenges as opportunities to grow.

  • I trust the process and take bold steps forward.

  • I am proud of how far I’ve come and excited for what’s next.

  • I deserve success, joy, and abundance in all areas of my life.

  • I am becoming the best version of myself every single day.

Test 1: Change Text Content​

  • Question: What will happen when the button is clicked?
<p id="greet">Welcome</p>
<button onclick="updateText()">Click</button>

<script>
function updateText() {
document.getElementById("greet").innerText = "Hello, Enoch!";
}
</script>

- A Nothing happens
- B "Welcome" becomes "Hello, Enoch!"
- C Page reloads
- D "Welcome" is removed

Answer: B - innerText changes the content inside the <p> tag.


Test 2: Toggling Visibility​

  • Question: What does this code do?
function toggle() {
const box = document.getElementById("box");
box.style.display = box.style.display === "none" ? "block" : "none";
}

A Changes text color B Shows/hides an element C Deletes the element D Animates the box

  • Answer: B - t toggles visibility between none and block.