Reverse Array
What is the result of reversing the array ['apple', 'banana', 'cherry']?
- ['apple', 'banana', 'cherry']
- ['banana', 'cherry', 'apple']
- ['cherry', 'banana', 'apple']
- ['apple', 'cherry', 'banana']
- ['chery', 'banana', 'apple']
Find Duplicate
Which method is most efficient for finding duplicate elements in a large array?
- Nested loops comparing each element to all others.
- Sorting the array and then comparing adjacent elements.
- Using a set to track seen elements and identify duplicates.
- Iterating through the array and counting occurences of each element.
- Randomly selecting elements and checking for matches.
Substring Search
What does the expression 'Hello World'.substring(6, 11) return?
- World
- Worl
- world
- Hello
- Error
Array Concatenation
If array1 is [1, 2, 3] and array2 is [4, 5, 6], what is the result of concatenating them?
- [1, 2, 3, 4, 5]
- [4, 5, 6, 1, 2, 3]
- [1, 2, 3, 4, 5, 6]
- [1, 4, 2, 5, 3, 6]
- [1, 2, 3],[4, 5, 6]
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'?
- string.replace('old', 'new')
- string.replaceAll('old', 'new')
- string.replace(/old/g, 'new')
- string.replace('old', 'new', 'g')
- string.changeAll('old', 'new')
Check for Palindrome
Which of these strings is a palindrome?
- hello
- level
- world
- algorithm
- programming
Array Splice
What does the 'splice' method do to an array?
- Returns a new array with a portion of the original array.
- Adds elements to the end of the array.
- Removes and/or replaces existing elements in an array.
- Checks if an array contains a specific element.
- Sorts the elements of an array.
String to Array
How do you convert the string 'apple,banana,cherry' into an array of strings?
- string.toArray()
- string.split(',')
- string.parseArray(',')
- string.separate(',')
- string.toArray(',')
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?
- By using a for loop
- By using a forEach loop
- By using the filter method
- By converting array to a Set, and then to an array.
- By converting array to a Set
String Contains
How can you verify that a string contains a specific substring?
- string.hasSubstring(substring)
- string.contains(substring)
- string.includes(substring)
- string.verify(substring)
- string.find(substring)