0
0
Javascriptprogramming~10 mins

Output using console.log in Javascript - Mini Project: Build & Apply

Choose your learning style9 modes available
Output using console.log
📖 Scenario: You want to greet your friend by showing a message on the screen using JavaScript.
🎯 Goal: Learn how to use console.log to display messages in the browser console.
📋 What You'll Learn
Create a variable with a greeting message
Use console.log to show the message
💡 Why This Matters
🌍 Real World
Developers use <code>console.log</code> to check values and debug their code while building websites or apps.
💼 Career
Knowing how to output messages helps you understand program flow and is a basic skill for any programming job.
Progress0 / 4 steps
1
Create a greeting message
Create a variable called greeting and set it to the string "Hello, friend!".
Javascript
Need a hint?

Use const to create a variable and put the message inside double quotes.

2
Use console.log to show the greeting
Write a line using console.log to display the variable greeting.
Javascript
Need a hint?

Use console.log(greeting); to print the message to the console.

3
Add a second message
Create a new variable called secondMessage and set it to "Welcome to JavaScript!". Then use console.log to display it.
Javascript
Need a hint?

Create the variable with const and print it with console.log.

4
Show both messages in the console
Run the program and check that the console shows both messages: Hello, friend! and Welcome to JavaScript!.
Javascript
Need a hint?

Open the browser console to see the messages printed one after the other.