Task 6: Writing Your First JavaScript Code
Start with Affirmation
- "I am destined for greatness. Every step I take brings me closer to my goals. I embrace challenges, knowing they are stepping stones to success. My mind is focused, my heart is determined, and my actions are aligned with my dreams."
Daily Affirmations for Success
- ✅ I am capable, confident, and unstoppable.
- ✅ Success flows to me because I take consistent action.
- ✅ I attract opportunities that align with my purpose.
- ✅ My hard work and persistence create abundance.
- ✅ I am always learning, growing, and evolving.
- ✅ I believe in my potential and trust my journey.
- ✅ I turn setbacks into comebacks with resilience.
- ✅ I am grateful for every success, big and small.
Success Reflection
"Every effort I made today has planted seeds for my future success. I release any doubts and trust the process. My dreams are possible, and I am getting closer every day. I am grateful, I am strong, and I am ready for more!"
💪 Repeat daily, feel the power, and watch your success unfold!
Task Answer - Video Link
🔹 If you don’t understand the task, watch the video above for the answer.
Task
** Step 1: Open the Browser Console
Follow these steps:
- 1️⃣ Open Google Chrome (or any browser like Firefox, Edge, or Safari).
- 2️⃣ Go to Google.com (or any website you like).
- 3️⃣ Right-click anywhere on the page and select Inspect.
- 4️⃣ Look for the Console tab and click on it.
If you don’t see it, try this shortcut:"
Windows/Linux: Ctrl + Shift + J
Mac: Cmd + Option + J
This is where we’ll type our JavaScript code!"
Step 2: Use JavaScript as a Calculator
Let’s start with something simple—math! Type this in the console and press Enter:
5 + 2
You should see the number 7 appear. Now, let’s try multiplication!"
5 * 2
Step 3: Storing Numbers in Variables
Now, let’s learn about variables. Think of them like a box where we can store something and use it later!"
Type this:
let myLuckyNumber = 7;
"Now, we’ve stored the number 7 inside a variable called myLuckyNumber. Let’s use it!"
10 + myLuckyNumber;
"JavaScript remembers that myLuckyNumber is 7, so it gives us 17 as the answer!"
Try it yourself! Change myLuckyNumber = 10 and see what happens!
Step 4: Storing and Using Text
"Variables don’t just store numbers, they can store text too! Let’s try it."
let myName = "Enoch";
"Now, our myName variable holds the text Alice. Let’s use it in a sentence!"
"Hello, my name is " + myName;
"JavaScript joins the words together and prints: Hello, my name is Enoch! 🎯"
Try it yourself! Change "Enoch" to your own name!
Step 5: Changing the Webpage Title
Let’s do something really cool—change the title of the webpage!"
document.title = "JavaScript is Easy!";
"Look at the browser tab! The title has changed to JavaScript is Awesome! That’s JavaScript in action!"
Try it yourself! Change "JavaScript is Easy!" to anything you want!
Step 6: Changing the Background Color of the Webpage
"Now, let’s make our webpage more colorful! We can change the background color using JavaScript!"
document.body.style.backgroundColor = "lightgreen";
"Look at the browser tab! The title has changed to JavaScript is Easy! That’s JavaScript in action!"
Try it yourself! Change "JavaScript is Easy!" to anything you want!
"And just like that, the webpage turns light green! Try different colors like yellow, green, or pink!"
Try it yourself! Experiment with different colors to see how they look!
Let’s quickly go over what we done today:
- ✅ Opened the browser console to write JavaScript.
- ✅ Used JavaScript as a calculator.
- ✅ Created variables to store numbers and text.
- ✅ Changed the webpage title and background color.
And this is just the beginning! In the next task, we’ll learn how to write functions—a superpower that makes JavaScript even more powerful!
"Try experimenting with different numbers, names, and colors. The more you play with JavaScript, the more you’ll understand it!"