Exam 8: Manipulating Data in Strings and Arrays

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

When applied to text strings, the term ____________________ refers to the act of extracting characters or substrings from a larger string.

Free
(Short Answer)
4.9/5
(44)
Correct Answer:
Verified

parsing

Explain the difference between the shift()and unshift()methods of the Array object.

Free
(Essay)
4.8/5
(37)
Correct Answer:
Verified

To add elements to or remove elements from the beginning of an array, you need to use the  shift( and unshift( methods. The shift( method  removes and returns the first  element from the beginning of an array, whereas the unshift( method  adds one or  more elements to the beginning of an array. You append the shift( method to the name  of the array whose first element you want to remove. You append the unshift( method  to the name of an array and pass to the method a comma-separated list of values for the  elements you want to add. For example, the following code declares and initializes an array  containing the names of five colors, and then uses the shift( and unshift( methods  to change the array contents:
  var colors = [ "mauve" , "periwinkle" , "silver" , "cherry" ,  "lemon" ];
  colors.shift(; // colors value now
  // ["periwinkle", "silver", "cherry", "lemon"]
  colors.unshift( "yellow-orange" , "violet" ;
  // colors value now ["yellow-orange", "violet",
  // "mauve", "periwinkle", "silver", "cherry", "lemon"]
The shift( method removes the first color, mauve, from the top of the array and  the unshift( method adds two new colors, yellow-orange and violet, to the top  of the array.

The JavaScript String class includes the ____ method, which creates a new string by combining strings that are passed as arguments.

Free
(Multiple Choice)
4.9/5
(34)
Correct Answer:
Verified

D

Regular expression patterns consist of literal characters and ____.

(Multiple Choice)
4.8/5
(38)

You use the ____ method of the String class to split a string into an indexed array.

(Multiple Choice)
4.9/5
(42)

The ____ method constructs a text string from Unicode character codes that are passed as arguments.

(Multiple Choice)
4.7/5
(29)

What is the difference between the slice()and substring()methods?

(Essay)
4.8/5
(35)

The ____ method of the String class returns the position number in a string of the first character in the argument.

(Multiple Choice)
4.9/5
(42)

Provide two different regular expressions that return true only when tested against a string consisting of exactly 5 characters.

(Short Answer)
4.8/5
(41)

The ____ object contains methods and properties for working with regular expressions in JavaScript.

(Multiple Choice)
4.8/5
(38)

The ____ method returns the position number in a string of the first instance of the first character in the pattern argument.

(Multiple Choice)
4.9/5
(35)

_________________________ are patterns that are used for matching and manipulating strings according to specified rules.

(Short Answer)
4.9/5
(45)

How can you combine text strings with JavaScript?

(Essay)
4.9/5
(34)

The replace() method is case sensitive.

(True/False)
4.8/5
(40)

To manipulate arrays in your scripts, you use the methods and length property of the ____ class.

(Multiple Choice)
4.8/5
(37)

__________ is a data format that represents a JavaScript object as a string.

(Short Answer)
4.9/5
(33)

How do you create a character class with JavaScript?

(Essay)
4.9/5
(39)

How can you match any metacharacters as literal values in a regular expression?

(Essay)
4.7/5
(42)

To allow a string to contain an alternate set of substrings, you separate the strings in a regular expression pattern with the ____ metacharacter.

(Multiple Choice)
4.9/5
(38)

The String class ____ property returns the number of characters in a string.

(Multiple Choice)
4.7/5
(40)
Showing 1 - 20 of 41
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)