Skip to main content

Task 23: Difference between Const and Let

Start with Affirmation​

  • "I am destined for greatness. Every step I take brings me closer to my goals. I embrace challenges, knowing they are stepping stones to success. My mind is focused, my heart is determined, and my actions are aligned with my dreams."

Daily Affirmations for Success

  • βœ… I am capable, confident, and unstoppable.
  • βœ… Success flows to me because I take consistent action.
  • βœ… I attract opportunities that align with my purpose.
  • βœ… My hard work and persistence create abundance.
  • βœ… I am always learning, growing, and evolving.
  • βœ… I believe in my potential and trust my journey.
  • βœ… I turn setbacks into comebacks with resilience.
  • βœ… I am grateful for every success, big and small.

Success Reflection​

"Every effort I made today has planted seeds for my future success. I release any doubts and trust the process. My dreams are possible, and I am getting closer every day. I am grateful, I am strong, and I am ready for more!"

πŸ’ͺ Repeat daily, feel the power, and watch your success unfold!


πŸ”Ή If you don’t understand the task, watch the video above for the answer.


Task​

Step 1​

<html>
<head>
<title>Superhero Card</title>
</head>
<body>
<h1>🦸 Superhero Profile</h1>
<p><strong>Name:</strong> <span id="heroName"></span></p>
<p><strong>Age:</strong> <span id="heroAge"></span></p>
<p><strong>Superpower:</strong> <span id="heroPower"></span></p>

<button onclick="showProfile()">Reveal My Hero!</button>

<script src="script.js"></script>
</body>
</html>

Step 2​

// Using const for values that never change
const heroName = "Captain Lukas"; // This name is fixed
const heroPower = "Book Blaster πŸ”§"; // Superpower also doesn't change

// Using let for values that might change later
let heroAge = 10; // Maybe our hero will age in future updates

// Function to show the profile in HTML
function showProfile() {
// Displaying the values inside the HTML
document.getElementById("heroName").textContent = heroName;
document.getElementById("heroAge").textContent = heroAge;
document.getElementById("heroPower").textContent = heroPower;

// Example of updating let variable
heroAge = heroAge + 1;
console.log(`Next year, ${heroName} will be ${heroAge} years old.`);
}