using the print function print happy earth day to the console

Celebrate Earth Day with Print: "Happy Earth Day"

By John White
AD

Happy Earth Day! Today, we celebrate our beautiful planet, and one way to participate is by spreading awareness through coding. Let's explore how to use the print function in several popular programming languages to display "Happy Earth Day" in your console.

Whether you're a seasoned developer or just starting your coding journey, understanding how to print text to the console is a fundamental skill. So let's dive into the world of programming to celebrate our planet.

JavaScript

JavaScript is a versatile language used primarily for web development. Here's how you can print "Happy Earth Day" to the console using JavaScript:

AD
a computer keyboard with a green save planet button on it
a computer keyboard with a green save planet button on it
happy earth day
happy earth day
an earth poster with animals, birds and flowers around it that says happy earth reduce reuse recycle
an earth poster with animals, birds and flowers around it that says happy earth reduce reuse recycle

console.log('Happy Earth Day');

Using Console.log with an Emoji

To make it more festive, you can use an Earth emoji right in your console. Here's how to do it:

a poster for the world earth day with a plant in it's center and words make your digital impressions count not your carbon footprints
a poster for the world earth day with a plant in it's center and words make your digital impressions count not your carbon footprints
Earth Day Greeting Card Printable 5x7 Eco Friendly Planet Design Sustainability Message Card
Earth Day Greeting Card Printable 5x7 Eco Friendly Planet Design Sustainability Message Card
🌍 Earth Day Poster | Save Our Planet 🌱
🌍 Earth Day Poster | Save Our Planet 🌱

console.log('Happy Earth Day 🌍');

Printing in a Styled Format

You can also print your message in a styled format using CSS. This won't change the console appearance but will make your "Happy Earth Day" message noticeable:

AD

console.log('%cHappy Earth Day', 'color: green; font-weight: bold;');

an earth day poster with hands holding the earth
an earth day poster with hands holding the earth
𝗛𝗔𝗣𝗣𝗬 π—ͺ𝗒π—₯π—Ÿπ—— π—˜π—”π—₯𝗧𝗛 𝗗𝗔𝗬!🌍 Let’s celebrate and honour our beautiful planet today and
𝗛𝗔𝗣𝗣𝗬 π—ͺ𝗒π—₯π—Ÿπ—— π—˜π—”π—₯𝗧𝗛 𝗗𝗔𝗬!🌍 Let’s celebrate and honour our beautiful planet today and
three bookmarks with different types of hand and earth images on them, one is for children
three bookmarks with different types of hand and earth images on them, one is for children
Digital Download- Because: Earth Day weekly calendar graphic
Digital Download- Because: Earth Day weekly calendar graphic
an image of a fingerprint with grass on it
an image of a fingerprint with grass on it
two hands holding up a green earth with wind turbines in the background
two hands holding up a green earth with wind turbines in the background

Python

Python is another popular language used in various applications, including data analysis and scientific computing.

Using the print() Function

Python has a built-in function called `print()`. Here's how you can use it to print "Happy Earth Day" to the console:

AD
print("Happy Earth Day")

Printing with an Emoji

You can also include an emoji in your message, just like in JavaScript:

an image of the earth day with animals and plants in it's numbers, including two
an image of the earth day with animals and plants in it's numbers, including two
Happy Earth Day!
Happy Earth Day!
the earth is shown with text that reads earth day, just went by and being the first sustainability moment on the calendar it sets the tone for what comes next
the earth is shown with text that reads earth day, just went by and being the first sustainability moment on the calendar it sets the tone for what comes next
print("Happy Earth Day 🌍")

Java

Java is a widely-used language for building business applications, games, and Android apps.

System.out.println()

Java uses `System.out.println()` to print text to the console. Here's how to use it:

AD
System.out.println("Happy Earth Day");

Printing with an Emoji

In Java, you can use the same approach as in Python and JavaScript to include an emoji in your message:

System.out.println("Happy Earth Day 🌍");

Don't forget, every act of kindness to our planet makes a difference. So keep coding, and happy Earth Day! 🌍

AD