Array and String Ninja Quiz Quiz

  1. Reverse Array

    What is the result of reversing the array ['apple', 'banana', 'cherry']?

    1. ['apple', 'banana', 'cherry']
    2. ['banana', 'cherry', 'apple']
    3. ['cherry', 'banana', 'apple']
    4. ['apple', 'cherry', 'banana']
    5. ['chery', 'banana', 'apple']
  2. Find Duplicate

    Which method is most efficient for finding duplicate elements in a large array?

    1. Nested loops comparing each element to all others.
    2. Sorting the array and then comparing adjacent elements.
    3. Using a set to track seen elements and identify duplicates.
    4. Iterating through the array and counting occurences of each element.
    5. Randomly selecting elements and checking for matches.
  3. Substring Search

    What does the expression 'Hello World'.substring(6, 11) return?

    1. World
    2. Worl
    3. world
    4. Hello
    5. Error
  4. Array Concatenation

    If array1 is [1, 2, 3] and array2 is [4, 5, 6], what is the result of concatenating them?

    1. [1, 2, 3, 4, 5]
    2. [4, 5, 6, 1, 2, 3]
    3. [1, 2, 3, 4, 5, 6]
    4. [1, 4, 2, 5, 3, 6]
    5. [1, 2, 3],[4, 5, 6]
  5. String Replacement

    How do you replace all occurrences of the word 'old' with the word 'new' in the string 'The old dog saw the old cat'?

    1. string.replace('old', 'new')
    2. string.replaceAll('old', 'new')
    3. string.replace(/old/g, 'new')
    4. string.replace('old', 'new', 'g')
    5. string.changeAll('old', 'new')
  6. Check for Palindrome

    Which of these strings is a palindrome?

    1. hello
    2. level
    3. world
    4. algorithm
    5. programming
  7. Array Splice

    What does the 'splice' method do to an array?

    1. Returns a new array with a portion of the original array.
    2. Adds elements to the end of the array.
    3. Removes and/or replaces existing elements in an array.
    4. Checks if an array contains a specific element.
    5. Sorts the elements of an array.
  8. String to Array

    How do you convert the string 'apple,banana,cherry' into an array of strings?

    1. string.toArray()
    2. string.split(',')
    3. string.parseArray(',')
    4. string.separate(',')
    5. string.toArray(',')
  9. Remove Duplicates

    Given an array [1, 2, 2, 3, 4, 4, 5], how do you remove duplicate values and return a new array with only unique values?

    1. By using a for loop
    2. By using a forEach loop
    3. By using the filter method
    4. By converting array to a Set, and then to an array.
    5. By converting array to a Set
  10. String Contains

    How can you verify that a string contains a specific substring?

    1. string.hasSubstring(substring)
    2. string.contains(substring)
    3. string.includes(substring)
    4. string.verify(substring)
    5. string.find(substring)