
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
18 questions
Nonfiction Review
Presentation
•
6th - 8th Grade
15 questions
The Eyes
Presentation
•
6th - 8th Grade
19 questions
Photosynthesis and Cellular Respiration
Presentation
•
6th - 8th Grade
19 questions
Introduction to Cricket
Presentation
•
6th - 8th Grade
16 questions
Images & Binary
Presentation
•
7th Grade
17 questions
Analyze Text Structure
Presentation
•
6th - 8th Grade
17 questions
Multiplying and Dividing Decimals
Presentation
•
6th - 8th Grade
16 questions
Paraphrasing
Presentation
•
6th - 8th Grade
Popular Resources on Wayground
10 questions
HCS SCI 03 Summer School Review 4
Quiz
•
3rd Grade
11 questions
HSMS - Standard Response Protocol
Quiz
•
6th - 8th Grade
16 questions
1.1-1.2 Quiz Review
Quiz
•
9th - 12th Grade
12 questions
Exponent Expressions
Quiz
•
6th Grade
20 questions
Adding and Subtracting Integers
Quiz
•
6th - 7th Grade
11 questions
Northeast States
Quiz
•
3rd - 4th Grade
10 questions
Characterization
Quiz
•
3rd - 7th Grade
10 questions
Common Denominators
Quiz
•
5th Grade
Discover more resources for Computers
11 questions
HSMS - Standard Response Protocol
Quiz
•
6th - 8th Grade
12 questions
Exponent Expressions
Quiz
•
6th Grade
20 questions
Adding and Subtracting Integers
Quiz
•
6th - 7th Grade
10 questions
Characterization
Quiz
•
3rd - 7th Grade
11 questions
Negative Exponents
Quiz
•
7th - 8th Grade
14 questions
Exponents
Quiz
•
6th Grade