Worksheets100Devs - LwL - Class 09 - JavaScript Intro
Total questions: 31
Worksheet time: 16mins
According to the golden rule: where does the behavior and interaction goes?
In a separate JavaScript file
inline with the html
On the server only
How many IDs can an element have?
One ID per element
As many as necessary
How many classes can an element have?
As many as necessary
One class per element
What does this represent in JS: || ?
OR
AND
BANG
What does this represent in JS: && ?
AND
BANG
OR
What is the DOM?
It is the rendering of the HTML code by the browser
It is the javaScript code in the JS file
It is code that will be changed in the HTML file
What can JavaScript do with the rendered page (DOM) on the browser?
It can alter the way the element are displayed, amongst other things
It can collect data inputs from the user
It can create new html elements on the browser
All are correct
Which element is being selected on this javascript snippet:
document.getElementById("purple")
The element on the DOM/HTML that has the id purple
The element on the DOM/HTML that has the class purple
Any element that is purple
What is an event listenter?
It is a way for javascript to wait for events, such as a click, to happen. And when they do happen, javascript acts
It is a way for HTML to wait for events, such as a click, to happen. And when they do happen, javascript acts
What are variables?
Variables tell the program to remember a value to be used later on.
Variables is a number that can be changed, like "x" in math
What is one way to declare a variable?
let nameOfTheVariable. let age, let height
just type the nameOfTheVariable. age = 25, height = "1.98m"
How to assign a value to a variable?
age = 25, height = 1.98. But first the variable must be declared.
let age, let height
What is a number or a string or an array?
They are data types
They are variables
What is a string?
It is a piece of text, that are always surrounded by "quotes"
It is a long piece of text, like a <p>
It is a short piece of text, like a <span>
What are integers?
It is a number type of data that has a value is a whole number: 25
It is a number type of data that has a value is a decimal number: 3.14
In JavaScript what are floats?
It is a number that has decimal places: 3.14
It is a number that has no decimals: 25
It is a string: "float"
What are basic arithmetic operations doable in JS?
+ - * / %
+ - * /
addition, subtraction, division and multiplication
What will this operation return? 5 * 2
10
2.5
1
What will this operation return? 5 / 2
2.5
10
1
What will this operation return? 5 % 2
1
10
2.5
52
Which of these is an event listener?
Both are correct
document.querySelector('#pumpkin').addEventListener('click', makeZero)
document.getElementById('purple').onclick = partyPurple
What will this comparison return: 9 === 9
TRUE
FALSE
What will this comparison return: 7 === 3
FALSE
TRUE
What will this comparison return: "hello" === "hello"
TRUE
FALSE
What will this comparison return: 3 == 8
FALSE
TRUE
What will this comparison return: 3 == 3
TRUE
FALSE
What will this comparison return: 3 === "3"
FALSE
TRUE
What will this comparison return: 3 == "3"
TRUE
FALSE
const age = 17
if (age >= 18){
console.log("you can get in")
} else if (age > 16) {
console.log("you're not quite ready")
}else {
console.log("You're too young")
}
What will this code return?
"you're not quite ready"
"you can get in"
"You're too young"
const fishSpecies = "clownfish"
const inhabitat = "anemone"
if (fishSpecies === "clownfish" && inhabitat === "anemone"){
console.log("welcome home, nemo")
} else{
console.log("only clownfish is allowed in the anemone")
}
What will this return?
"only clownfish is allowed in the anemone"
"welcome home, nemo"
if (name === "Leon" &&
hair ==="gorgeous")
{ //run code } What must be true so the code runs?
name must be Leon and hair must be gorgeous
Either name must be Leon or hair must be gorgeous
