Quiz 5, 6 & 7 Flashcards

1
Q

T/F - Javascript only provides one way to add Event Listeners to Elements

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how can you retrieve an element with the id “first”?

A

document.querySelector(“#first”) and document.getElementById(“first”) both work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T/F - The methods getElementsByClassName() and getElementsByTagName() both return an array-like list of the matched elements, even if the match is for a single element.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

T/F - if your html code contains the following element:

<p>The quick brown fox jumped the fence.</p>

The following javascript code will change the color of the paragraph to red?
document.fox.style.color = “red”;

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the first step in adding event handling to your JavaScript code?

A

identifying the DOM node the interactive behavior will be attached to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Given the following code:

<ul>
<li>HTML for content</li>
<li>CSS for presentation</li>
<li>JavaScript for functionality</li>
</ul>

how we can select all the li elements?

A

document.getElementsByTagName(“li”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

document.getElementsByClassName(“test”)[0].innerHTML = “Hello”;

A

Change the text of the first element that has the class name “test”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

T/F - one of the benefits of scripting language is that it can accomplish the task quickly without concern for machine efficiency because it is interpretable and dynamically typed language

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F - The following code will generate a random number (from 0-99) each time we click the button” Add a number”

<html>
<body>

<script>
function addRandomNumber(){
let el = document.createElement("p");
el.innerText = Math.floor(Math.random() * 100);
document.body.appendChild(el);
}
</script>

<button>Add a number</button>
</body>
</html>
A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which properties are included in the box model?

A

height, padding, and border

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the rem unit based on?

A

The rem unit is relative to the font-size of the root element of the page. In HTML the root element is <html>.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

T/F - Given the following rule
. grid {
display: grid;
width:500px;
grid-template-columns:100px 1fr 1fr;
}
The first column will have a width of 100px. The second column will be 150px wide and the third column will be 300px wide.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Select the option that is NOT a valid JavaScript Datatype

String
Int
Number
Boolean

A

Int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

T/F - JavaScript is used to add interactive content to Web Sites

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What will be the result of the JavaScript expression (31 + “ angry polar bears”)

A

“31 angry polar bears”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When a user views a page containing a JavaScript program, which machine actually executes the script?

A

The user’s machine running a web browser

17
Q

In JS, which equality operator would you use to assure two variables are both the same value, and the same type

A

===

18
Q

T/F - JavaScript is a weakly typed language

A

True