0
0
Javascriptprogramming~15 mins

Why variables are needed in Javascript - See It in Action

Choose your learning style9 modes available
Why variables are needed
📖 Scenario: Imagine you are organizing a small party. You need to keep track of how many guests will come, what snacks to buy, and how much money you have to spend. Variables in programming help you store and remember such information so you can use it later.
🎯 Goal: You will create variables to store information about a party and then use those variables to display a message about the party details.
📋 What You'll Learn
Create variables with exact names and values as instructed
Use variables to build a message string
Print the message to the console
💡 Why This Matters
🌍 Real World
Variables are like labeled boxes where you keep important information. In real life, you might write down a shopping list or keep track of your allowance. In programming, variables help keep track of data so the computer can use it.
💼 Career
Understanding variables is the first step in programming. Every software developer uses variables to store and manage data, making this skill essential for any coding job.
Progress0 / 4 steps
1
Create variables for party details
Create a variable called guestCount and set it to 10. Create another variable called snack and set it to "chips".
Javascript
Need a hint?

Use let to create variables and assign the exact values given.

2
Add a variable for budget
Create a variable called budget and set it to 50.
Javascript
Need a hint?

Remember to use let and assign the number 50 to budget.

3
Create a message using variables
Create a variable called message and set it to a string using the variables guestCount, snack, and budget in this exact format: `We have ${guestCount} guests coming, will buy ${snack}, and have $${budget} to spend.`
Javascript
Need a hint?

Use backticks ` to create a template string and insert variables with ${}.

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.