Test 1 Flashcards

(138 cards)

1
Q
  1. Which of the following is something you must have to run JavaScript?
    a. a web browser
    b. a program compiler
    c. software that generates code for the web
    d. all of the above
A

Answer: a. a web browser

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. The choice of a web browser is up to you, as long it’s compatible with ________.
    a. scripting plug-ins
    b. VBScript
    c. the version of JavaScript that you are using
    d. any Windows operating system
A

Answer: c. the version of JavaScript that you are using

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. JavaScript and Java are the same language. (true or false )
A

Answer:False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. JavaScript has similarities to other programming and scripting languages. (true or false )
A

Answer: True

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

Before its release as JavaScript, JavaScript was originally called __________.

a. Java
b. PerlScript
c. LiveScript
d. EasyScript

A

Answer: c.LiveScript

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

JavaScript was first introduced into which browser?

a. Netscape Navigator
b. Internet Explorer
c. Apple Safari
d. It was introduced into both A and B at the same time

A

Answer: a. Netscape Navigator

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

JavaScript is __________.

a. object based
b. function based
c. based on module structures
d. not a language that uses objects as does VBScript

A

Answer: A. object based

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

A _____ language doesn’t require a program to be compiled before it is run.

a. programming
b. server-side
c. scripting
d. all of the above

A

Answer: C. scripting

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

In a scripting language, the code is interpreted as it is loaded in the client. (ture/false)

A

Answer: True

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

In JavaScript, what handles errors in a script when it executes?

a. the web server
b. a programming compiler
c. the local computer’s operating system
d. all of the above

A

Answer: a. the web server

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

What HTML code is added to a web page in order to insert JavaScript code?

a. script tags
b. js tags
c. javascript tags
d. Both A and C are correct

A

script tags

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

As part of the parsing process, the browser creates a type of internal model known as a DOM (Document Object Model) representation based on the content of the loaded document. (ture or false)

A

Answer:True

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

The top level of the DOM hierarchy is occupied by _____________________.

a. the document object
b. the document method
c. the window method
d. the window object

A

Answer: d. the window object

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

When writing scripts, the window object must always be called as the first object in your hierarchy structure. (true or false )

A

Answer: false

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

The notation that we use to represent objects in the document tree structure uses the _____________________ to denote the hierarchy structure.

a. backslash
b. forward slash
c. dot or period
d. all of the above can be used

A

Answer: c. dot or period

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

The alert( ) method is a method that is part of which object (structure)?

a. the document object
b. the window object
c. both A and B
d. neither A nor B

A

Answer: b.the window object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
The alert( ) method generates a message box whose appearance cannot be customized; it’s appearance is solely determined by the browser being used.  
(true or false )
A

Answer: True

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

The main limitation of using JavaScript in a web page is based on the fact that if it is applied for use as a client-side script, you cannot combine it with any type of client-side scripting such as ASP or PHP. (true or false )

A

Answer: True

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

. To write a string of text on a web page, the __________ method is used.

a. document.write ()
b. document.print ()
c. document,type ()
d. window.print ()

A

Answer: a. document.write ()

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

The __________ signals the end of a JavaScript statement.

a. colon
b. period
c. question mark
d. semicolon

A

Answer: d. semicolon

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

What is the purpose of the script > and script tags?

a. To tell the browser where a script begins and ends
b. To let the browser know the scripting language to be used
c. To point to an external JavaScript file
d. All of the above

A

Answer: d. All of the above

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

An external JavaScript file commonly uses a filename extension of ________.

a. .js
b. .html
c. .jav
d. .java

A

Answer: a. .js

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

Which of the following correctly points to an external JavaScript file named yourfile.js?

a. javascript type=“text/javascript” src=“yourfile.js”>
b. script type= “text/javascript” src=“yourfile.js”>
c. script href=“yourfile.js”>
d. javascript type=“text/javascript” href=“yourfile.js”>

A

Answer: b.

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

You cannot use any HTML tags – including the script tag – in your external JavaScript file being linked to your web page; you must include ONLY JavaScript code. (true or false)

A

Answer: True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
. Although it is NOT recommended, you can name your external JavaScript file using any file extension and the browser will try to interpret its content as JavaScript. ( true or false )
Answer: true
26
JavaScript code statements are interpreted and executed as they are encountered as your web page is being parsed. (true or false)
Answer: True
27
When would it be a good idea to use an external JavaScript file? a. When the script is short or going to be used in only one HTML document b. When your Web site viewers have older browsers c. When the script is very long or needs to be placed in more than one HTML document d. External files can be a problem if the link fails causing your pages to function incorrectly and for this reason should be avoided whenever possible
Answer: c. When the script is very long or needs to be placed in more than one HTML document
28
. In JavaScript, you must declare the existence of a variable before you can assign a value to it. (true or false )
Answer: False
29
JavaScript variable names are case sensitive. (true or false )
Answer : True
30
Which of the following indicates the end of a multiple-line JavaScript comment? a. \\ b. --> c. / * d. */
Answer: d. */
31
. Which of the following indicates that a single line of commentary will follow it within JavaScript code? a. / * b. / -- c. // d. < !--
Answer : c. //
32
Which of the following indicates that more than one line of commentary will follow it within JavaScript code? a. / * b. / -- c. / / d. < !—
Answer: a. / *
33
. Which of the following characters are not valid when naming JavaScript variables? a. alphanumeric b. $ c. underscores d. all of the above are valid
Answer: d. all of the above are valid
34
To calculate the remainder from a division equation, you can use JavaScript’s ____________ operator. a. precedence b. modulus c. increment d. decrement
Answer : b. modulus
35
The symbol to increment a variable value is ___; the decrement symbol is ___. a. + ; - b. ++ ; -- c. +- ; -+ d. =+ ; =-
Answer: b. ++ ; --
36
The __________ determines the order in which mathematical calculations will be executed in an equation. a. numerical value(s) being used b. mathematical operators (symbols) being used c. order of precedence d. both B and C
Answer: d. both B and C
37
The only arithmetic symbol that can be used on strings is the ____ symbol. a. / b. - c. + d. *
Answer: c. +
38
JavaScript can be executed when an event occurs; which of the following is not an example of a JavaScript event: a. when an animated gif current view changes from one image to another b. when the User writes something in a search field c. when a document view is resized d. when the User copies the content of an element on a web page
Answer: a. when an animated gif current view changes from one image to another
39
Which of the following is not an example of a JavaScript event handler: a. onmouseleave b. onmouseup c. onmouseclick d. onmouseenter
Answer: c. onmouseclick
40
When adding an event handler to your page, the code can be placed directly inside the HTML element without requiring the code to be written inside of tags or to use the script attribute. (true or false )
Answer : True
41
. Which of the following variable declarations uses a variable with a valid variable name in JavaScript? a. var default; b. var my_house; c. var my dog; d. var 2cats;
Answer: b. var my_house;
42
To denote an exponent in JavaScript, you use _________ right after the base number and before the exponent. a. the lowercase letter “ x “ b. the lowercase letter “ e “ c. the pound sign “ # “ d. the ampersand sign “ & “
Answer: b. the lowercase letter “ e “
43
Which of the following string declarations is invalid? a. var mytext=“Here is some text!”; b. var mytext=‘Here is some text!’; c. var mytext= Here is some text!; d. var mytext= “Here is \n some text!”;
Answer: a. var mytext=“Here is some text!”;
44
Which of the following statements would be valid in JavaScript? a. document.write (“John said, “Hi!””); b. document.write (‘John said, “Hi!””); c. document.write (“John said, “Hi!’”); d. document.write (“John said, \“Hi!\””);
Answer: c. document.write (“John said, “Hi!’”);
45
Which of the following successfully prints a variable named myhobby by adding it to a set of strings? a. document.write (“I like to +myhobby+ every weekend”); b. document.write (“I like to ” +myhobby+ “ every weekend”); c. document.write (“I like to myhobby every weekend”); d. document.write (“I like to ‘myhobby’ every weekend”);
Answer: b. document.write (“I like to ” +myhobby+ “ every weekend”);
46
. When a + operator is used between a numeric and non-numeric value, JavaScript: a. converts the string to a numeric value and adds the two; b. converts the numeric value to a string and concatenates the two; c. if the first value is numeric, it converts the string to a numeric value and adds the two, and if the first value is a string, it converts the numeric value to a string and concatenates the two; d. generates an error;
Answer: b. converts the numeric value to a string and concatenates the two;
47
. How many elements are permitted in a web page’s code? a. only one b. one in the section and one in the section c. as many as needed d. none – they can only be used in a .js file and imported into the web page
Answer : c. as many as needed
48
To declare a function, you use the reserved word(s) __________. a. var function b. new function c. function d. Function
Answer: c. function
49
What are two main reasons why a function can be useful? a. They make simple scripts more complex, and they make it easier for non-coders to read the script. b. They provide a way to organize the various parts of the script into the different tasks that must be accomplished, and they can be reused. c. They make simple scripts more complex, and they can be reused. d. They provide a way to organize the various parts of the script into the different tasks that must be accomplished, and they make it harder for non- coders to access and/or execute the script without authorization.
Answer: b. They provide a way to organize the various parts of the script into the different tasks that must be accomplished, and they can be reused.
50
What surrounds the code inside a function? a. curly brackets – { } b. colons – :: c. square brackets – [ ] d. nothing
Answer : a. curly brackets – { }
51
Which of the following would be a valid function name in JavaScript? a. function my function () b. function 24hours () c. function get_text () d. all of the above-listed names are valid
Answer : c function get_text ()
52
__________ are used to allow a function to import one or more values from outside the function into the function in order to have access to the values necessary to execute the function. a. event handlers b. arguments c. document objects d. document classes
Answer : b. arguments
53
Function names are case sensitive. ( True or false )
Answer : True
54
In a function, parameters/arguments are separated by what symbol? a. period b. colon c. semicolon d. comma
Answer : d. comma
55
. Arguments are set up on the first line of a function, inside a set of ______. a. curly brackets – { } b. parentheses – ( ) c. square brackets – [ ] d. double quotes – “ “
Answer: b. parentheses – ( )
56
Which of the following correctly calls a function named some_alert( ) and sends it two string values as arguments? a. some_alert (some, words); b. some_alert (“some”, “words”); c. some_alert (“some, words”); d. all of the above are valid syntax
Answer: b. some_alert (“some”, “words”);
57
Which of the following correctly assigns the result of a function named get_something( ) to a variable named shopping? a. var shopping=get_something ( ); b. var shopping=“get_something ( )”; c. var shopping=get something ( ); d. all of the above will work
Answer : a. var shopping=get_something ( );
58
A function does not execute at the place in the code where it is created; in order for it to be executed, the function must first be specifically called. (true or false )
Answer: True
59
. Functions do not have to be defined before they are called ( true or false )
Answer : false
60
There is NO limit to the number of arguments that can be defined when creating a function. (true or false )
Answer : True
61
The same number of arguments must be passed to the function when it is called as are defined in the function definition. (true or false )
Answer ( true )
62
It is important that the names given to arguments in the definition of your function have nothing to do with the names of any variables whose values are passed to the function when it is called; they should be different. (true or false )
Answer : true
63
. In order to return a function’s executed results, the keyword __________ must be used inside the function definition. a. results b. global c. return d. local
Answer : c. return
64
All functions must be given a name when they are created. ( true or false )
Answer : false
65
When you create a function that will only be used once, you can assign it to an object right then without having to name it and call it later; this is referred to as using a(n) ___________________. a. aynonymous function b. global assignment c. singular function d. direct assignment
Answer : a. aynonymous function
66
Which of the following is not a characteristic of an anonymous function: a. they do not have to be named when they are created b. they must contain a set of ( ) symbols after the keyword, function c. they must be used at the time they are created d. once created, they can be used repeatedly throughout your document
Answer: d. once created, they can be used repeatedly throughout your document
67
Variables declared inside a function only exist inside that function. ( true or false )
Answer : True
68
. Where a variable is defined and where it can be used inside a program’s code is known as its ______. a. allowance b. scope c. range d. parameter
Answer: b. scope
69
Variables declared inside a function definition are known as _____ variables. a. native b. global c. limited d. local
Answer: d. local
70
When you use the keyword "this" inside a function or method, it refers to the function’s ________________. a. global assignment b. code itself c. child object d. parent object
Answer : d parent object
71
When you use the keyword "this" inside a function, it refers to whatever “owns” the function – something we refer to as the parent scope of the function. (true or false )
Answer : true
72
Block scope in JavaScript constitutes the entire content of code that is located within a pair of curly braces. ( true or false )
Answer : true
73
In JavaScript, the new keyword ______ allows you to declare a variable while limiting its scope to the block in which it is declared. a. let b. const c. allow d. permit
answer : a. let
74
``` In JavaScript, the new keyword ______ creates a constant with a read-only, named variable. a. constant b. const c. con d. constn ```
Answer: b. const
75
Any value declared as a constant can have its value changed at any point in a program’s code but only once and only if it is changed from within a function call. ( true or false )
Answer : false
76
The __________ function is represented by the symbol(s) _______. a. arrow ; <= b. arrow ; => c. anonymous ; <= d. anonymous ; =>
Answer : b. arrow ; =>
77
The arrow function is shorthand syntax for an anonymous function. ( true or false )
Answer : true
78
The => symbol is often referred to as the ______________ symbol. a. anonymous function b. arrow function c. redirection arrow d. fat arrow
Answer :d. fat arrow
79
. Functions can be created with a __________________ which can be used if no argument value is given. a. block scope value b. global scope c. anonymous value d. default parameter
Answer : d. default parameter
80
When defining a default parameter value, it must always come before nondefault parameter values in the function definition. ( true or false )
Answer : False
81
The confirm dialog box offers the User a choice; they may choose between a(n) _______ button or a(n) _______ button. a. OK ; Cancel b. OK ; Close c. Enter ; Cancel d. Enter ; Close
Answer : a. OK ; Cancel
82
In a confirm dialog box, the User’s choice is returned as a(n) ______ value. a. boolean b. integer c. string d. all of the above are correct depending on the code set-up that creates it
Answer : a. boolean
83
A prompt dialog box is used when you want to collect some piece of information or data from the User. (true or false )
Answer : true
84
A prompt dialog box can be set up so that a default value is assigned in case the User fails to enter any data into the text box. (true or false )
Answer : true
85
Which is not a true statement regarding the prompt dialog box: a. if the User types in input and clicks OK or presses Enter, the User’s inputted string will be returned b. if the User clicks OK or presses Enter without typing anything into the dialog box, a default is returned (if any has been assigned), c. if the User clicks OK or presses Enter without typing anything into the dialog box and no default value has been assigned, the boolean value, false, will be returned d. if the User dismisses the dialog box by clicking Cancel or pressing Escape, then the value of null is returned
Answer : c. if the User clicks OK or presses Enter without typing anything into the dialog box and no default value has been assigned, the boolean value, false, will be returned
86
To select an HTML element on your page with a specific Id value, you will use the _____________ method. a. GetElementsById( ) b. GetElementById( ) c. getElementsById( ) d. getElementById( )
Answer : d. getElementById( )
87
. The _________ property allows you to get or set the value of the HTML content inside a particular page element. a. setInnerHTML b. getInnerHTML c. InnerHTML d. innerHTML
Answer : d. innerHTML
88
The only property owned by the history object is its ___________. a. scope b. length c. id d. date
Answer : b. length
89
Which one is not a method of the history object: a. jumpto( ) b. go( ) c. forward( ) d. back( )
answer : a. jumpto( )
90
The __________ object contains information about the URL of the currently loaded page. a. href b. location c. source d. path
Answer : b. location
91
. A web page loaded into a browser has the following URL: http://www.eBay.com/form/form1.htm?page=4 ; what will the location.pathname property of the location object contain? a. http://www.eBay.com b. www.eBay.com/form c. /form/form1.htm d. /form/form1.htm?page=4
Answer : c. /form/form1.htm
92
A web page loaded into a browser has the following URL: http://www.eBay.com/form/form1.htm?page=4 ; what will the location.href property of the location object contain? a. http://www.eBay.com b. www.eBay.com/form c. http://www.eBay.com/form/form1.htm?page=4 d. www.eBay.com/form/form1.htm?page=4
Answer : c. http://www.eBay.com/form/form1.htm?page=4
93
A web page loaded into a browser has the following URL:http://www.eBay.com/form/form1.htm?page=4 ; what will the location.hostname property of the location object contain? a. www.eBay.com b. http://www.eBay.com/form c. http://www.eBay.com/form/form1.htm?page=4 d. www.eBay.com/form/form1.htm
answer : a. www.eBay.com
94
The location object can take a User to a new page by applying which method(s): a. directly set the href property of the object to the new URL b. use the replace( ) method to set the new URL c. use the reload( ) method to set the new URL d. both A and B are correct
Answer : d. both A and B are correct
95
To reload a web page directly from the server and not from the browser’s cache, which of the following would be the correct code to use: a. location.reload(true); b. document.reload(true); c. location.reload( ); d. document.reload( );
Answer : b. document.reload(true);
96
The ______ object’s properties contain data about the browser application itself. a. document b. window c. browser d. navigator
Answer : d. navigator
97
Date objects are not created automatically as part of the DOM; they must be created at the time of use. (true or false )
Answer : True
98
Which of the following will successfully create a new Date object and assign its value to a variable: a. var currentDate = Date( ); b. var currentDate = Date; c. var currentDate = new Date( ); d. var currentDate = new Date;
Answer : c. var currentDate = new Date( );
99
The _________ method will display a four-digit year for a new Date object. a. FullYear( ) b. fullYear( ) c. getFullYear( ) d. GetFullYear( )
Answer : c. getFullYear( )
100
The _______ method will display the day of the week for a new Date object. a. GetWeekday( ) b. getWeekday( ) c. getDay( ) d. GetDay( )
Answer : c. getDay( )
101
The _______ method will display the day of the month for a new Date object. a. GetDate( ) b. getDate( ) c. getDay( ) d. GetDay( )
Answer : b. getDate( )
102
The _______ method will display the time in hours for a new Date object. a. GetHours( ) b. getHours( ) c. getTimeHours( ) d. GetTimeHours( )
Answer : b. getHours( )
103
Which of the following methods will not be useful for truncating the decimal part of numbers: a. truncate( ) b. ceil( ) c. floor( ) d. round( )
Answer : a. truncate( )
104
The Math object must be created before it can be used. ( true or false )
Answer: False
105
The _______ method will generate a random number between ___ and ___. a. Math.random( ) ; 0 ; 1 b. Math.random( ) ; 0 ; 100 c. Math.Random( ) ; 0 ; 1 d. Math.Random( ) ; 0 ; 100
Answer : a. Math.random( ) ; 0 ; 1
106
In JavaScript, you do not have to declare a variable’s data type before usage. ( true or false )
Answer ( true )
107
JavaScript supports floating-point numbers but not integers, so if you need to use the later, you will need to first convert them to a decimal point numerical value before attempting to use them. (true or false )
Answer : False
108
. JavaScript does not have the ability to handle hexadecimal numbers – only base-10 and binary values. ( true or false )
Answer: False
109
In JavaScript, you have access to global methods that can be used to manipulate numerical values and are available to be used anywhere in your code. ( true or false )
Answer : True
110
The _____________ method returns a number as a character string. a. toString( ) b. parseString( ) c. ToString( ) d. ParseString( )
Answer : a. toString( )
111
In referencing the correct method name found in question #5 just above, if you pass this method a _________ value between the value range of _________, it will convert the numerical base of the number to which it is applied. a. realix ; 2 - 36 b. realix ; 2 - 32 c. radix ; 2 – 36 d. radix ; 2 – 32
Answer : c. radix ; 2 – 36
112
``` What is the output of the following lines of code: var t = 22; alert ( t.toString(16) ); a. 00010110 b. 16 c. 34 d. none of the above are correct ```
Answer : b. 16
113
The _____________ method returns a string, but with the number written with a specified number of decimal places. a. toFixedNum( ) b. toFixedNumber( ) c. toFixedFloat( ) d. toFixed( )
Answer : d. toFixed( )
114
``` The _____________ method returns a number rounded and written out using exponential notation. a. parseExponent( ) b. parseExponential( ) c. toExponent( ) d. toExponential( ) ```
Answer : d. toExponential( )
115
Usually you do not have to worry about creating Number objects yourself because JavaScript converts numerical values to instances of the class, Number. ( true or false )
Answer: true
116
``` Which of the following tries to convert the passed argument to a numerical value before testing: a. Number.isNaN( ) b. isNaN( ) c. Number.isNotaNum( ) d. isNotaNum( ) ```
b. isNaN( )
117
Which of the following determines whether or not an argument or expression passed to it evaluates to an integer: a. isNaInt( ) b. isNotInteger( ) c. isInteger( ) d. isNotaInt( )
c. isInteger( )
118
The ________ function parses a string and returns a floating-point number. a. parseFloat( ) b. ParseFloat( ) c. Parsefloat( ) d. parsefloat( )
a. parseFloat( )
119
. The ______ function parses a string and returns either an integer value or NaN. a. parseInt( ) b. parseInteger( ) c. ParseInteger( ) d. ParseInt( )
a. parseInt( )
120
. Infinity is larger than the largest number that JavaScript can represent, so you can test for infinite values by using the ____________ function. a. IsFinite( ) b. isFinite( ) c. IsInfinite( ) d. isInfinite( )
b. isFinite( )
121
When you pass an argument to the isNumber( ) function, it will do it’s best to return a numerical equivalent. T F
False
122
JavaScript interprets any non-zero value as true and zero as false. T F
True
123
. Which of the following values does JavaScript define as false: a. NaN b. undefined c. null d. all of the above
all of the above
124
``` When you assign the value ___________ to something, you want it to have a valid but nonexistent value. a. NaN b. undefined c. null d. all of the above ```
c.null
125
. ____________ is a predefined global variable used to store the value of a variable whose name has been used in a statement but does not have a value assigned to it. a. NaN b. Undefined c. Null d. all of the above
b. Undefined
126
``` In evaluating the follow code, which second line of code will return the length of the string argument that is being passed: var newText = “JavaScript is cool!”; ???????????????? a. alert(newText.length); b. alert(length.newText); c. newText.alert(length); d. newText.length.alert( ); ```
a. alert(newText.length);
127
To use a character not found on your keyboard or a special character, you can do so by preceding the character with a ________, and it is known as a(n)____________________. a. / (forward slash) ; switched sequence b. / (forward slash) ; escaped sequence c. \ (backslash) ; switched sequence d. \ (backslash) ; escaped sequence
d. \ (backslash) ; escaped sequence
128
The ______________ method and ______________ method puts all of the characters in a string into either uppercase or lowercase respectively. a. strUpperCase( ) ; strLowerCase( ) b. toUppercase( ) ; toLowercase( ) c. UpperCase( ) ; LowerCase( ) d. toUpperCase( ) ; toLowerCase( )
d. toUpperCase( ) ; toLowerCase( )
129
4. In JavaScript, strings are immutable, meaning that they cannot be changed; instead, you can only make new versions of strings that already exist. T F
True
130
The ______ string method joins strings and returns a copy of the joined string. a. Concat( ) b. concat( ) c. join( ) d. Join( )
c. join()
131
The index of the first character in a string is ____ . a. 0 b. 1 c. undefined until referenced / called d. may be either depending upon the usage of the string in the program’s code
b. 1
132
. For a string called myString containing the value “dumb as a box of rocks,” which of the following would return a value of -1? a. myString.indexOf (“as dumb as”); b. myString.indexOf (“dumb as a box”); c. myString.lastIndexOf (“box of rocks”); d. myString.lastIndexOf (“dumb”);
a. myString.indexOf (“as dumb as”);
133
For a string called myString containing the value “call as soon as you can,” what would the return value be after running the following line of code: myString.lastIndexOf (“as”); a. 5 b. 6 c. 13 d. 14
a.5
134
The __________ method returns a new string which consists of a specified number of copies of the string it was called on; the number of copies required can be passed as an argument. a. match( ) b. duplicate ( ) c. copy( ) d. repeat ( )
d. repeat ( )
135
``` When referencing the following line of code: var string1 = “JavaScript makes me happy!” ``` which of the following will return a new string with the substring “happy” replaced by the substring “crazy”? a. var newString = string1.subst(“happy”, ”crazy”); b. var newString = string1.replace(“happy”, ”crazy”); c. var newString = string1.subst(“crazy”, ”happy”); d. var newString = string1.replace(“crazy”, ”happy”);
b. var newString = string1.replace(“happy”, ”crazy”);
136
``` The _____________ method enables you to split a string into an array of substrings and return the new array. a. split( ) b. div( ) c. substr( ) d. section( ) ```
a. split( )
137
What does the following code return: var string1 = “JavaScript is a very easy language to learn!” var newString = string1.substr(14); a. extracts “JavaScript is ” b. extracts “JavaScript is a” c. extracts “a very easy language to learn!” d. extracts “ a very easy l”
c. extracts “a very easy language to learn!”
138
Template strings have one major drawback in that they cannot span multiple lines. T F
false