Search Header Logo

JavaScript Basics

Authored by Richard Ghiorse

Computers

9th - 12th Grade

Used 4+ times

JavaScript Basics
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following will change the entire body of the HTML on a webpage to the text "Hacked by JavaScript"

document.innerHTML = "Hacked by JavaScript";

document.body = "Hacked by JavaScript";

document.body.innerHTML = "Hacked by JavaScript";

body = "Hacked by JavaScript";

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following JavaScript commands will change the HTML associated with any id "title" to the text "ECS is Fun".

document.title.innerHTML = "ECS is Fun";

document.getElementById("title").innerHTML = "ECS is Fun";

document.getElementById(title).innerHTML = ECS is Fun;

document.getElementById("title") = "ECS is Fun";

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following correctly uses a JavaScript variable that is initialized to 42?

var num = 42;

num = 42;

var 42;

var 42 = num;

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following stores all the HTML elements with the tag h2 into a variable called headings?

var headings = document.getElementsByTagName("h2");

var headings = getElementsByTagName("h2");

var headings = document.getElementsByTagName(h2);

headings = document.getElementsByTag(h2);

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Suppose we have the following JavaScript variable to retrieve all the paragraphs on a webpage:

var paragraphs = document.getElementsByTagName("p");

Which of the following changes the text of the second paragraph to "The second paragraph has been hacked!"

paragraphs[2] = "The second paragraph has been hacked!";

paragraphs[1] = "The second paragraph has been hacked!";

paragraphs[2].innerHTML = "The second paragraph has been hacked!";

paragraphs[1].innerHTML = "The second paragraph has been hacked!";

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?