Finding Array Length
Which JavaScript property returns the number of elements in an array named 'myArray'?
- myArray.length
- myArray.size()
- myArray.count
- myArray.lenght
- myArray.getLength()
Reversing a String
In Python, which code correctly reverses the string variable 'text'?
- text[::-1]
- text.reverse()
- reverse(text)
- text.reversed()
- text[]
Joining Array Elements
What is the result of ','.join(['a', 'b', 'c']) in Python?
- 'a,b,c'
- 'abc'
- ['a,b,c']
- 'a|b|c'
- Error
Checking for Substring
How do you check in JavaScript if the word 'apple' exists within the string 'fruitBasket'?
- fruitBasket.includes('apple')
- fruitBasket.has('apple')
- fruitBasket.isIncluded('apple')
- fruitBasket.contains('apple')
- fruitBasket.find('apple')
Splitting Text
In JavaScript, what does 'Learn,Quiz,Practice'.split(',') return?
- ['Learn', 'Quiz', 'Practice']
- 'Learn Quiz Practice'
- ['Learn Quiz Practice']
- 'Learn','Quiz','Practice'
- ['Learn',Quiz,Practice]
Array IndexOf
What is the output of ['red', 'blue', 'green'].indexOf('blue') in JavaScript?
- 1
- 0
- 'blue'
- 2
- -1
String Case Conversion
How do you convert string s = 'Python' to all uppercase in Python?
- s.upper()
- upper(s)
- s.toUpper()
- s.UPPER()
- s.toupper()
Removing the Last Array Element
Which JavaScript method removes and returns the last element of an array arr?
- arr.pop()
- arr.remove()
- arr.shift()
- arr.deleteLast()
- arr.cut()
Slicing an Array
In Python, what does nums[1:3] return for nums = [10, 20, 30, 40]?
- [20, 30]
- [10, 20, 30]
- [20, 30, 40]
- [10, 30, 40]
- [30, 40]
Replacing Substrings
How do you replace all instances of 'cat' with 'dog' in the string s = 'cat scat cat' in Python?
- s.replace('cat', 'dog')
- replace(s, 'cat', 'dog')
- s.replaceAll('cat','dog')
- s.change('cat','dog')
- s.substitute('cat','dog')