Arrays and Strings Manipulation Mastery Quiz Quiz

  1. Finding Array Length

    Which JavaScript property returns the number of elements in an array named 'myArray'?

    1. myArray.length
    2. myArray.size()
    3. myArray.count
    4. myArray.lenght
    5. myArray.getLength()
  2. Reversing a String

    In Python, which code correctly reverses the string variable 'text'?

    1. text[::-1]
    2. text.reverse()
    3. reverse(text)
    4. text.reversed()
    5. text[]
  3. Joining Array Elements

    What is the result of ','.join(['a', 'b', 'c']) in Python?

    1. 'a,b,c'
    2. 'abc'
    3. ['a,b,c']
    4. 'a|b|c'
    5. Error
  4. Checking for Substring

    How do you check in JavaScript if the word 'apple' exists within the string 'fruitBasket'?

    1. fruitBasket.includes('apple')
    2. fruitBasket.has('apple')
    3. fruitBasket.isIncluded('apple')
    4. fruitBasket.contains('apple')
    5. fruitBasket.find('apple')
  5. Splitting Text

    In JavaScript, what does 'Learn,Quiz,Practice'.split(',') return?

    1. ['Learn', 'Quiz', 'Practice']
    2. 'Learn Quiz Practice'
    3. ['Learn Quiz Practice']
    4. 'Learn','Quiz','Practice'
    5. ['Learn',Quiz,Practice]
  6. Array IndexOf

    What is the output of ['red', 'blue', 'green'].indexOf('blue') in JavaScript?

    1. 1
    2. 0
    3. 'blue'
    4. 2
    5. -1
  7. String Case Conversion

    How do you convert string s = 'Python' to all uppercase in Python?

    1. s.upper()
    2. upper(s)
    3. s.toUpper()
    4. s.UPPER()
    5. s.toupper()
  8. Removing the Last Array Element

    Which JavaScript method removes and returns the last element of an array arr?

    1. arr.pop()
    2. arr.remove()
    3. arr.shift()
    4. arr.deleteLast()
    5. arr.cut()
  9. Slicing an Array

    In Python, what does nums[1:3] return for nums = [10, 20, 30, 40]?

    1. [20, 30]
    2. [10, 20, 30]
    3. [20, 30, 40]
    4. [10, 30, 40]
    5. [30, 40]
  10. Replacing Substrings

    How do you replace all instances of 'cat' with 'dog' in the string s = 'cat scat cat' in Python?

    1. s.replace('cat', 'dog')
    2. replace(s, 'cat', 'dog')
    3. s.replaceAll('cat','dog')
    4. s.change('cat','dog')
    5. s.substitute('cat','dog')