Array practice (part 2)

Complete the following exercises to improve your understanding of javascript functions!

Tests for each of these have been written and can be found in this repo. Fork and git clone it to make use of the tests! Detailed instructions in the test repo.

  1. Write a JavaScript function to remove a specific element from an array.

    • Sample input: removeArrayElement([2, 5, 9, 6], 5))
    • Sample output: [2, 9, 6]
  2. Write a JavaScript function to get nth largest element from an unsorted array.

    • Sample input: nthlargest([ 43, 56, 23, 89, 88, 90, 99, 652], 4)
    • Sample output: 89
  3. Write a JavaScript function to get a random item from an array.

    • Sample input: randomItem(['hello', 'hi', 'bye'])
    • Sample output: 'hello' // or 'hi', or 'bye'!
  4. Write a JavaScript function to generate an array of specified length, filled with integer numbers, increase by a specific step from starting position.

    • Sample input: arrayRange(1, 4, 1))
    • Sample output: [1, 2, 3, 4]

    • Sample input: arrayRange(-6, 5, 2)

    • Sample output: [-6, -4, -2, 0, 2]

results matching ""

    No results matching ""