Lesson Plan
Your First JavaScript Spell!
Students will be able to define JavaScript, identify its applications in web development, and write a basic JavaScript command to display output in a browser console.
Understanding JavaScript is crucial for anyone interested in modern web development, interactive websites, and even mobile apps. This lesson provides a foundational understanding to spark interest and equip students with a valuable new skill.
Audience
11th Grade
Time
30 minutes
Approach
Interactive lecture, guided coding, and hands-on exploration.
Materials
Smartboard or projector, Computers with internet access and a web browser (like Chrome or Firefox), JavaScript Intro Slide Deck, Teacher Script: Your First JavaScript Spell!, Warm-Up: Code Commander!, Cool-Down: My JavaScript Journey, and First JavaScript Spell Worksheet
Prep
Teacher Preparation
15 minutes
- Review the JavaScript Intro Slide Deck and become familiar with each slide's content and notes.
- Read through the Teacher Script: Your First JavaScript Spell! to ensure a smooth delivery and anticipate potential student questions.
- Ensure all student computers have a working web browser and internet access.
- Familiarize yourself with opening the developer console in your chosen browser (Ctrl+Shift+I or F12 in most browsers).
- Print copies of the First JavaScript Spell Worksheet if you plan to use it for in-class work or homework.
- Review the generated materials as needed, paying special attention to the code examples and explanations to ensure clarity and accuracy for your students.
- Prepare to demonstrate opening the developer console and typing code live.
Step 1
Warm-Up: Code Commander!
5 minutes
- Distribute the Warm-Up: Code Commander!.
- Instruct students to complete the warm-up individually.
- Briefly review answers as a class, discussing initial thoughts on 'programming.'
Step 2
Introduction to JavaScript (Slides & Discussion)
10 minutes
- Begin presenting the JavaScript Intro Slide Deck using the Teacher Script: Your First JavaScript Spell!.
- Introduce JavaScript: what it is and why it's powerful (Slide 1-3).
- Discuss where JavaScript is used in everyday websites (Slide 4-5).
- Lead a brief discussion on student experiences with interactive websites.
Step 3
Your First JavaScript Spell: Console.log()
10 minutes
- Transition to hands-on coding (Slide 6).
- Instruct students to open their web browser and then open the developer console (Ctrl+Shift+I or F12).
- Guide students through typing their first
console.log("Hello, World!");command, explaining each part (Slide 7). - Encourage students to experiment with different messages. Provide support as needed. (Refer to First JavaScript Spell Worksheet for additional practice if time allows.)
Step 4
Cool-Down: My JavaScript Journey
5 minutes
- Distribute the Cool-Down: My JavaScript Journey.
- Ask students to reflect on what they learned and one question they still have.
- Collect the cool-downs as an exit ticket.
use Lenny to create lessons.
No credit card needed
Slide Deck
Your First JavaScript Spell!
Unlocking the Power of the Web
- What makes websites move?
- How do buttons work?
- Let's find out!
Welcome students and introduce the topic: JavaScript! Ask them if they've ever wondered how websites do cool, interactive things. Briefly explain that today they'll learn about the 'magic' behind it.
What is JavaScript?
The Web's Action Hero!
- JavaScript (JS) is a programming language.
- It brings websites to life!
- Makes things interactive and dynamic.
- Think of it as the 'brain' of a webpage.
Explain what JavaScript is in simple terms. Emphasize its role in making websites dynamic and interactive. Compare it to HTML (structure) and CSS (style) to provide context.
Where Do We See JS?
Everywhere You Look!
- Interactive forms: Checking your input.
- Image sliders/carousels: Moving pictures.
- Animated graphics: Cool visual effects.
- Pop-ups and notifications: Timely messages.
- Games within browsers: Yes, even games!
Provide examples of where JavaScript is commonly used. Engage students by asking them to think of interactive features they've seen online. This helps connect the abstract concept to their real-world experience.
Your Secret Lab: The Browser Console
A Place to Practice Your Spells!
- Web browsers (like Chrome or Firefox) have special tools.
- One of these is the Developer Console.
- It's where we can:
- See messages from our code.
- Test out JavaScript commands directly!
- Shortcut:
Ctrl+Shift+IorF12(on most keyboards)
Introduce the idea of the browser console as a place to write and test JavaScript. Explain it's a developer tool, and students will get to use it like a secret lab.
Our First Spell: console.log()
Making Your Computer Talk!
console.log()is a command that tells the browser to print something.- We use it to see if our code is working.
- Syntax:
console.log("Your message here!");console.logis the command.("...")is what we want to print.;tells the computer the command is finished.
- Try it yourself!
Introduce the console.log() command as the first 'spell.' Explain its purpose (displaying messages) and walk them through the syntax. Emphasize the quotation marks and semicolon.
You're a JavaScript Apprentice!
What We Learned Today:
- JavaScript makes websites interactive.
- It's used everywhere on the web.
- You can write JS in the browser console.
- Your first spell:
console.log("Hello, World!");
Keep Exploring!
- There's so much more to learn!
Conclude the lesson by summarizing what they learned and encouraging further exploration. Reiterate the power of JavaScript.
Script
Teacher Script: Your First JavaScript Spell!
Warm-Up: Code Commander! (5 minutes)
Teacher: "Good morning/afternoon, class! Today we're going to dive into something that makes almost every website you visit exciting and interactive. Before we jump in, let's get our brains warmed up with a quick activity. Please take one of these Warm-Up: Code Commander! sheets and complete it individually. Think about what it means to give instructions."
(Allow students 3-4 minutes to complete the warm-up. Circulate and observe.)
Teacher: "Alright, let's quickly go over some of your ideas. Who can share what they wrote for the first question? What kinds of instructions do you give every day?" (Call on a few students.) "Great! And for the second question, what do you think would happen if those instructions weren't clear?" (Guide discussion towards the importance of clear, precise instructions, connecting it to how computers need instructions.)
Introduction to JavaScript (Slides & Discussion) (10 minutes)
Teacher: (Transition to the JavaScript Intro Slide Deck, Slide 1) "Fantastic! That idea of giving clear instructions is exactly what we're going to explore today with computers. Our lesson is titled 'Your First JavaScript Spell!' because by the end of this, you'll feel like you've learned a bit of magic for the internet!"
(Advance to Slide 2)
Teacher: "So, what exactly is JavaScript? Imagine the internet as a huge, bustling city. HTML is like the buildings and roads – the structure. CSS is like the paint, decorations, and landscaping – making everything look good. But what makes the cars move, the traffic lights change, the elevators go up and down? That's JavaScript!"
"JavaScript, often shortened to JS, is a powerful programming language. Its main job is to bring websites to life, making them interactive and dynamic. It's essentially the 'brain' of a webpage, telling it what to do when you click a button, scroll, or fill out a form."
(Advance to Slide 3)
Teacher: "You probably interact with JavaScript every single day without even realizing it! Can anyone think of an example of something interactive they've seen on a website?"
(Wait for responses, prompt if needed: e.g., "What happens when you log into a social media site? How does a shopping cart work? What about those cool image galleries?")
"Exactly! When you see interactive forms checking your input, image sliders moving automatically, cool animations, pop-up messages, or even games directly in your browser – that's all JavaScript at work. It's truly everywhere, making your online experience richer and more engaging."
Your First JavaScript Spell: Console.log() (10 minutes)
Teacher: (Advance to Slide 4) "Now, how do we actually talk to JavaScript? We're going to use something called the Developer Console. Think of it as your secret lab, a special place inside your web browser where you can write and test JavaScript commands directly."
"To open it, everyone please open a new tab in your web browser – Chrome, Firefox, Edge, whatever you use is fine. Once you have a blank page or any website open, you can usually open the Developer Console by pressing Ctrl + Shift + I (that's the letter i) or simply F12 on your keyboard. Give it a try now."
(Give students a moment to open their consoles. Provide assistance as needed. Ensure they are on the 'Console' tab if there are multiple.)
Teacher: "You should see a panel pop up, often at the bottom or side of your browser. Find the tab that says 'Console.' This is where we'll cast our first spell!"
(Advance to Slide 5)
Teacher: "Our first spell is a very useful command called console.log(). This command simply tells the browser to print whatever you put inside the parentheses. It's super helpful for checking if our code is working correctly or just to display messages."
"Let's break down the syntax: console.log("Your message here!");
console.logis the command itself, like saying 'print this.'- The parentheses
()hold what we want to print. - Inside the parentheses, the quotation marks
" "are important. They tell JavaScript that what's inside is a piece of text, a 'string.' - And finally, the semicolon
;at the end acts like a period in a sentence – it tells JavaScript that this command is finished."
"Now, in your console, at the blinking cursor where you can type, type this exactly as you see it on the slide: console.log("Hello, World!"); and then press Enter."
(Guide students as they type their first command. Troubleshoot typos. Celebrate their first output!)
Teacher: "Amazing! You've just written and executed your first line of JavaScript! You told the computer to say 'Hello, World!' What if you wanted it to say something else? Try changing the message inside the quotation marks. Maybe console.log("My name is [Your Name]"); or console.log("JavaScript is cool!"); Experiment a bit!"
(Circulate, encourage experimentation, and offer help.)
"If you're feeling adventurous, you can also try numbers without quotes, like console.log(5 + 3); and see what happens!"
Cool-Down: My JavaScript Journey (5 minutes)
Teacher: (Advance to Slide 6) "Excellent work, future web developers! Today was just a tiny peek into the vast world of JavaScript. You now know what it is, where it lives, and how to make it say 'Hello!'"
"To wrap up, please take one of these Cool-Down: My JavaScript Journey sheets. I'd like you to write down one thing you learned today and one question you still have about JavaScript or coding in general. This helps me understand what clicked and what we might explore next."
(Distribute cool-downs. Collect them as students finish.)
Teacher: "Thank you all for your fantastic participation today! I hope you enjoyed casting your first JavaScript spell. Keep an eye out for more JavaScript magic as you browse the web!"
Warm Up
Warm-Up: Code Commander!
Name: _________________________
Date: __________________________
Think Like a Computer!
Imagine you are giving instructions to a robot. Robots need very clear and specific instructions to do anything.
-
What is one set of instructions you give or follow every day? (For example: how to make a sandwich, how to get to school, how to tie your shoes.)
Describe these instructions in simple, step-by-step detail, as if you were explaining them to a robot who knows nothing.
-
Why is it important for instructions to be clear and precise when talking to a robot (or a computer)? What might happen if your instructions are confusing or incomplete?
-
Bonus Challenge: Write a very simple instruction for a robot to say "Hello!"
Cool Down
Cool-Down: My JavaScript Journey
Name: _________________________
Date: __________________________
Reflect and Cast!
-
What is one new thing you learned about JavaScript or web development today?
-
What is one question you still have about JavaScript or how computers follow instructions?
-
Imagine you could make a website do ONE cool, interactive thing using JavaScript. What would it be?
Worksheet
First JavaScript Spell Worksheet
Name: _________________________
Date: __________________________
Practice Your console.log()!
Instructions: For each problem, write the console.log() command that would display the requested message in the browser's developer console. Remember to use quotation marks for text and a semicolon at the end!
-
Display the message: "Hello, JavaScript World!"
console.log(
-
Display your favorite color. (e.g., "My favorite color is blue.")
console.log(
-
Display the answer to 10 + 5. (Hint: You can do math directly! No quotes needed for numbers.)
console.log(
-
Display a short, encouraging message to yourself. (e.g., "You got this!")
console.log(
-
Challenge: Display your name and your age on separate lines in the console. (You'll need two
console.log()commands!)console.log(
console.log(
Answer Key
First JavaScript Spell Answer Key
Practice Your console.log()!
Instructions: These are example answers. Students' specific messages for questions 2, 4, and 5 will vary but should follow the correct syntax.
-
Display the message: "Hello, JavaScript World!"
console.log("Hello, JavaScript World!");Thought Process: The request is to display a specific text string. Therefore, the text needs to be enclosed in double quotes within the
console.log()function, followed by a semicolon. -
Display your favorite color. (e.g., "My favorite color is blue.")
console.log("My favorite color is blue.");
(Student answer may vary for the color.)Thought Process: Similar to question 1, this requires displaying a text string, so the custom message should be inside double quotes within
console.log()and end with a semicolon. -
Display the answer to 10 + 5. (Hint: You can do math directly! No quotes needed for numbers.)
console.log(10 + 5);
(Output will be 15)Thought Process: The hint specifies that numbers don't need quotes for mathematical operations. The expression
10 + 5is placed directly insideconsole.log()to evaluate and display the sum. -
Display a short, encouraging message to yourself. (e.g., "You got this!")
console.log("You got this!");
(Student answer may vary for the message.)Thought Process: This is another instance of displaying a custom text string, requiring the message to be in double quotes within
console.log()and terminated with a semicolon. -
Challenge: Display your name and your age on separate lines in the console. (You'll need two
console.log()commands!)console.log("My Name is Lenny.");
console.log("I am 25 years old.");
(Student answers will vary for name and age.)Thought Process: To display two separate pieces of information on different lines, two distinct
console.log()commands are needed. Each command will display its respective text string (name and age) enclosed in double quotes and ending with a semicolon.