0
0
Javascriptprogramming~10 mins

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

Choose your learning style9 modes available
Variable declaration using var
📖 Scenario: Imagine you are organizing a small party. You want to keep track of the number of guests coming and the name of the party.
🎯 Goal: You will create variables using var to store the party name and the number of guests, then display them.
📋 What You'll Learn
Use var to declare variables
Assign exact values to variables as instructed
Print the variables to show their values
💡 Why This Matters
🌍 Real World
Variables help store information like names and counts in many programs, such as event planners or games.
💼 Career
Understanding variable declaration is a basic skill for any programming job, enabling you to store and manage data.
Progress0 / 4 steps
1
Declare a variable for the party name
Declare a variable called partyName using var and set it to the string "Birthday Bash".
Javascript
Need a hint?

Use var partyName = "Birthday Bash"; to create the variable.

2
Declare a variable for the number of guests
Declare a variable called guestCount using var and set it to the number 15.
Javascript
Need a hint?

Use var guestCount = 15; to create the variable.

3
Create a message using the variables
Declare a variable called message using var and set it to a string that says "Welcome to Birthday Bash! We have 15 guests." by combining partyName and guestCount with string concatenation.
Javascript
Need a hint?

Use var message = "Welcome to " + partyName + "! We have " + guestCount + " guests."; to create the message.

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

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