Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 1.3 KB

File metadata and controls

33 lines (22 loc) · 1.3 KB

Here are 10 short practice questions focused on array methods


  1. Remove Duplicates: Write a function that takes an array of numbers and returns a new array with duplicate values removed.

  2. Find Max Number: Write a function that finds and returns the largest number in a given array of integers.

  3. Array Reversal: Write a function that takes an array and returns a new array with the elements in reverse order.

  4. Custom Push: Write a function that adds a new element to the end of an array without using .push().

  5. Count Occurrences: Write a function that takes an array and a value, and returns how many times that value appears in the array.

  6. Insert at Index: Write a function that inserts a value at a given index in an array, shifting other elements accordingly.

  7. Remove by Value: Write a function that removes the first occurrence of a given value from an array.

  8. Swap Elements: Write a function that swaps two elements in an array based on their indices.

  9. Flatten Array (1 level): Write a function that takes a 2D array and flattens it into a 1D array (assume only one level of nesting).

  10. Rotate Array: Write a function that rotates an array to the right by one position. For example, [1,2,3,4] becomes [4,1,2,3].