
Learn Javascript (1)
Presentation
•
Computers
•
6th - 8th Grade
•
Practice Problem
•
Easy
cam darr
Used 4+ times
FREE Resource
6 Slides • 16 Questions
1
JavaScript (1)
By cam darr
2
What is JavaScript?
JavaScript (JS) is a programming language that makes websites interactive. It allows you to:
Show alerts and messages
Create animations
Handle user input (e.g., button clicks)
Update webpage content dynamically
It runs in web browsers, meaning you don’t need to install anything special to start coding.
Running JavaScript
You can run JavaScript in two simple ways:
A. Using the Browser Console
Open a web browser (Chrome, Firefox, Edge, etc.).
Right-click on a webpage and select Inspect (or press F12 or Ctrl + Shift + I).
Go to the Console tab.
Type this and press Enter:
This prints a message to the console.
3
Variables store data. You can create them using let, const, or var.
let allows changing the value later.
const is for values that don’t change.
var is older and mostly avoided.
Try this in your browser console:
Variables
When a variable is declared, but not defined it will always output "undefined" when printed in the console.
For example:
let x;
console.log(x);
You can also print multiple variables in the console using commas. In this example it prints: "Alice 25"
4
Multiple Choice
Which keyword is used to declare a variable that can change later?
const
var
let
5
Multiple Choice
Which keyword is used to declare a variable that cannot change?
const
var
let
6
Multiple Choice
What will be printed in the console?
error
undefined
7
Multiple Choice
What's wrong with this code? Fix it so it runs correctly.
let city = "Los Angeles";
console.log('city');
let city = "New York";
console.log(city);
let city = "New York";
city = "Los Angeles";
console.log(city);
const city = "Los Angeles";
city = "New York";
8
Multiple Choice
What will be printed in the console?
Error
false
9
JavaScript Data Types
JavaScript has different types of data that you can store in variables. Here are the main ones:
When this is printed it will look something like this:
Hello 30 true undefined null Array (3)
0: "apple"
1: "banana"
2: "cherry"
length: 3
Object
age: 25
name: "Alice"
Note: Objects are printed alphabetically. In the example age is first and then name.
10
JavaScript Operators
Operators are used to perform operations on variables and values. Don't forget that coding will involve a lot of math!
Arithmetic Operators (Math Operations):
Comparison Operators (True/False Checks)
Still don't get it? This key might help:
= means "equal"
! means "not"
> means "greater than"
< means "less than"
11
Logical Operators
Logical operators in JavaScript are used to perform logical operations between two or more values. They help to evaluate conditions and return boolean values (true or false). These operators are essential in controlling the flow of logic in decision-making structures like if statements, loops, and other conditional expressions.
AND (&&)
The AND operator is used to check if both conditions are true. If both conditions are true, it returns true; otherwise, it returns false.
Syntax: condition1 && condition2
Example:
true && false // returns false
OR (||)
The OR operator is used to check if at least one of the conditions is true. If either condition is true, it returns true. If both are false, it returns false.
Syntax: condition1 || condition2
Example:
true || false // returns true
NOT (!)
The NOT operator is used to reverse the boolean value of a condition. If the condition is true, it becomes false, and vice versa.
Syntax: !condition
Example:
!true // returns false
These logical operators are commonly used in if statements to evaluate multiple conditions:
let age = 25;
let hasPermission = true;
if (age >= 18 && hasPermission) {
console.log("You can enter.");
}
In this example, the && operator checks if both age >= 18 and hasPermission are true before allowing entry.
Short-Circuiting
Logical operators in JavaScript have short-circuit behavior:
AND (&&): If the first condition is false, the second condition is not evaluated.
OR (||): If the first condition is true, the second condition is not evaluated.
This feature can improve performance by preventing unnecessary evaluations of conditions.
12
Multiple Choice
Which of the following is a valid example of a String in JavaScript?
true
42
"Hello, World!"
{ name: "Alice" }
13
Multiple Choice
What is the type of the variable let isHappy = true;?
Number
Boolean
String
Undefined
14
Multiple Choice
What will be the output of the following code? (Hint: Objects are printed alphabetically)
Hello 30 true undefined null ["apple", "banana", "cherry"] { , age: 25, name: "Alice" }
Hello 30 true NaN null ["apple", "banana", "cherry"] { , age: 25, name: "Alice" }
Hello, true, 30, undefined, null, ["apple", "banana", "cherry"], { name: "Alice", age: 25 }
30 true undefined NaN null ["apple", "banana", "cherry"] { name: "Alice", age: 25 }
15
Multiple Choice
What will be the result of 10 % 3?
3
1
0
10
16
Multiple Choice
Which operator is used for exponentiation (power) in JavaScript?
* (asterisk)
** (double asterisk)
% (percent)
^ (caret)
17
Multiple Choice
What will the following code output?
100
30
1000
7
18
Multiple Choice
What will be the output of the following code?
true false
false true
true true
false false
19
Multiple Choice
Which operator checks both the value and type of two variables?
==
!=
===
!==
20
Multiple Choice
What will be the result of the following expression?
true
false
undefined
NaN
21
Multiple Choice
What is the output of the following code?
false
true
undefined
NaN
22
Multiple Choice
The following code doesn't work properly:
Replace !true with true!
Replace !true with false
Replace !true with !false
JavaScript (1)
By cam darr
Show answer
Auto Play
Slide 1 / 22
SLIDE
Similar Resources on Wayground
17 questions
Culinary Arts Pretest
Presentation
•
6th - 8th Grade
17 questions
DNA Intro
Presentation
•
6th - 8th Grade
16 questions
Track Jumping Events
Presentation
•
6th - 8th Grade
16 questions
What is a Memoir?
Presentation
•
6th - 8th Grade
16 questions
Exponential Form
Presentation
•
6th - 8th Grade
16 questions
Pixar Animation
Presentation
•
7th - 8th Grade
19 questions
Artificial Intelligence
Presentation
•
6th - 9th Grade
20 questions
Computer Networks
Presentation
•
6th - 9th Grade
Popular Resources on Wayground
20 questions
STAAR Review Quiz #3
Quiz
•
8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
6 questions
Marshmallow Farm Quiz
Quiz
•
2nd - 5th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
12 questions
What makes Nebraska's government unique?
Quiz
•
4th - 5th Grade
Discover more resources for Computers
20 questions
STAAR Review Quiz #3
Quiz
•
8th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
20 questions
Revising & Editing practice
Quiz
•
7th Grade
10 questions
Box Plots
Quiz
•
6th - 7th Grade
8 questions
Amoeba Sister Asexual vs Sexual Reproduction
Interactive video
•
8th Grade
10 questions
April Fool's Day Pranks and Tips
Interactive video
•
3rd - 6th Grade
14 questions
Volume of rectangular prisms
Quiz
•
7th Grade