Pushpa 1
Pushpa 1
Question 1:
Input:
Array = [1, 2, 3, 4, 5]
Task: Multiply each element by its index position in the array.
Expected Output: [0, 2, 6, 12, 20]
Question 2:
Input:
Array = [1, 1, 2, 3, 5]
Task: Find the sum of only the even numbers.
Expected Output: 6
Question 3:
Input:
Array = [100, 200, 300, 400]
Task: Remove the last two elements and return the modified array.
Expected Output: [100, 200]
Question 4:
Input:
Array = [5, 10, 15]
Task: Add 20 to the array.
Expected Output: [5, 10, 15, 20]
Question 5:
Input:
Array = [100, 200, 300, 400]
Task: Remove the first two elements and return the modified array.
Expected Output: [300, 400]
Question 6:
Input:
Array = [100, 200, 300]
Task: Add 50 and 75 to the start of the array.
Expected Output: [50, 75, 100, 200, 300]
Question 7:
Input:
Arrays = [[1], [2], [3]]
Task: Merge all three arrays.
Expected Output: [1, 2, 3]
Question 8:
Input:
Array = [2, 4, 6, 8]
Task: Create a new array where each element is squared.
Expected Output: [4, 16, 36, 64]
Question 9:
Input:
Array = [3, 6, 9, 12]
Task: Filter the array to get only numbers that are divisible by 3.
Expected Output: [3, 6, 9, 12]
Question 10:
Input:
Array = [5, 10, 15], index = 0, deleteCount = 2, addItem = 7, 8
Task: Modify the array by removing 2 elements starting from index 0 and adding 7 and 8.
Expected Output: [7, 8, 15]
Question 11:
Input:
Array = [5, 10, 15, 20], start = 2
Task: Extract a portion of the array from index 2 to the end.
Expected Output: [15, 20]
Question 12:
Input:
Array = [100, 200, 300]
Task: Print each element of the array reduced by 50.
Expected Output:
50
150
250
Question 13:
Input:
String = "apple-orange-banana"
Task: Split the string by hyphens.
Expected Output: ['apple', 'orange', 'banana']
Question 14:
Input:
Array = ['dog', 'cat', 'mouse'], separator = ' '
Task: Join the array elements into a single string, separated by a space.
Expected Output: "dog cat mouse"
Question 15:
Input:
Array = [true, false, true]
Task: Convert the array to a string.
Expected Output: "true,false,true"