Question: In this practice, you will be provided some skeleton code of functions that execute for-loops in a specified manner. Your job is to read the

In this practice, you will be provided some skeleton code of functions that execute for-loops in a specified manner.

Your job is to read the description of each function and write the code that returns an array with the proper contents.

function oddIndices(arr) { // Return an array containing all the odd indices in the array // Your code here } function oddReverse(arr) { // Return an array containing all the odd indices starting from the end // Your code here } function secondPower(arr) { // Return an array containing all indices that are powers of 2 // Your code here } function nthPower(arr, n) { // Return an array containing all indices that are powers of n // Your code here } function firstHalf(arr) { // Return an array containing the first half of an array // Include middle index on odd length arr // Your code here } function secondHalf(arr) { // Return an array containing the second half of an array // Exclude middle index on odd length arr // Your code here } module.exports = { oddIndices, oddReverse, secondPower, nthPower, firstHalf, secondHalf }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!