Chapter 6: JavaScript: Introduction to Scripting

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

6.1 In the following line the word document is a(n) ______ that resides in the computer's memory.

document.writeln("Hello World");

a) attribute

b) behavior

c) object

d) method

c) object

2
New cards

6.2 In the following line, the word writeln is a(n) _________ that performs a task or action in the script.

document.writeln("Hello World");

a) structure

b) collection

c) object

d) method

d) method

3
New cards

6.3 Consider the following HTML5 code.

<html>
<script type = "text/javascript">
<!--
<!-- document.writeln("Hello World"); -->
//-->
</script>
</html>

What would a browser capable of scripting display when executing this code?

a) document.writeln("Hello World");

b) nothing

c) Hello World

d)

b) nothing

4
New cards

6.4 Which of the following statements would correctly print out the sentence "Hello World" in blue?

a) document.write( "

");

b) document.write( "

style = \"color: blue\" Hello World

);

c) document.write( "

");

d) document.write( "

");

document.write( "Hello World

");

d) document.write( "

");

document.write( "Hello World

");

5
New cards

6.5 An alert dialog displaying the text "Welcome!" is created by calling _________.

a) window.alert( "Welcome!" );

b) alert.window( "Welcome!" );

c) window( "alert = \"Welcome!\"" );

d) window( " Welcome! " );

a) window.alert( "Welcome!" );

6
New cards

6.6 Consider the following script. What is wrong with the following code?

<script type = "text/javascript">
var firstNumber;
thirdNumber;

firstNumber = window.prompt("Enter an integer", "0");
secondNumber = window.prompt("Enter an integer", "0");
thirdNumber = firstNumber + secondNumber;
</script>

a) thirdNumber in line 7 must be in quotes.

b) The words Enter an integer in line 6 should not be in quotes.

c) The word thirdnumber in line 3 should have a comma after it.

d) The word var must be placed before thirdNumber in line 3.

d) The word var must be placed before thirdNumber in line 3.

7
New cards

6.7 Which of the following is not a valid variable name?

a) Tax1

b) eightball_8

c) 12footage

d) pageNumber1200

c) 12footage

8
New cards

6.8 What will the browser display if the following script is executed and the user enters 5 at both prompts?

<script type = "text/javascript">
<!--
var firstNumber = window.prompt( "Enter an integer", "0" );
var secondNumber= window.prompt( "Enter an integer", "0" );
var thirdNumber;
thirdNumber = firstNumber + secondNumber;
document.write( thirdNumber );
//-

a) nothing

b) 0

c) 10

d) 55

d) 55

9
New cards

6.9 Whenever a value is placed in a memory location, the value________.

a) cannot be added if a value already exists

b) can share a location in memory with another value

c) replaces the previous value in that location

d) will be assigned to another identifier if a value already exists

c) replaces the previous value in that location

10
New cards

6.10 What is the result of the statement 17 % 5?

a) 0

b) 2

c) 3

d) 12

b) 2

11
New cards

6.11 Which of the following sequences does not follow the rules of operator precedence? Assume that operators are evaluated in the order listed from left to right.

a) multiplication, division, addition

b) parentheses, subtraction, modulus

c) division, multiplication, addition

d) parentheses, modulus, subtraction

b) parentheses, subtraction, modulus

12
New cards

6.12 What does the following expression evaluate to?

( ( 3 + ( 5 + 4 ) * 7 ) + 4 ) / 5

a) 8

b) 14

c) 17.6

d) 26.4

b) 14

13
New cards

6.13 Which of the following is not a valid JavaScript equality or relational operator?

a) =

b) <

c) >

c)!=

a) =

14
New cards

6.14 Which of the following operators associates from right to left?

a) ==

b) =

c) +

d) %

b) =