0
0
Javascriptprogramming~10 mins

Variable declaration using let in Javascript - Mini Project: Build & Apply

Choose your learning style9 modes available
Variable declaration using let
📖 Scenario: Imagine you are organizing a small party and need to keep track of the number of guests coming.
🎯 Goal: You will create a variable to store the number of guests using let, update it, and then display the final count.
📋 What You'll Learn
Create a variable using let with the exact name guestCount
Initialize guestCount with the value 5
Update guestCount by adding 3
Print the final value of guestCount
💡 Why This Matters
🌍 Real World
Keeping track of counts or quantities in programs, like guests, items, or scores.
💼 Career
Understanding variable declaration and updates is fundamental for all programming jobs.
Progress0 / 4 steps
1
Declare the initial variable
Create a variable called guestCount using let and set it to 5.
Javascript
Need a hint?

Use let guestCount = 5; to declare the variable.

2
Update the variable
Add 3 to the existing guestCount variable using the += operator.
Javascript
Need a hint?

Use guestCount += 3; to add 3 to the current value.

3
Use the variable in a message
Create a new variable called message using let and set it to the string `Total guests: ${guestCount}` using a template literal.
Javascript
Need a hint?

Use backticks ` and ${guestCount} inside the string.

4
Display the message
Use console.log to print the message variable.
Javascript
Need a hint?

Use console.log(message); to show the message in the console.