Skip to content

davified/array-practice-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 

Repository files navigation

More array practice

Complete the following exercises to improve your understanding of arrays in javascript!

Instructions:

  • In main.js, define the functions listed below and test that it works by running it against helper.test(yourFunction(), yourExpectedValue).
  • As opposed to manually checking the output every time you run the function, we've written a helper method (helper.test()) to help you check whether your code produces the expected output. Write your own tests, and then write code to pass the test. You can use the sample inputs and expected outputs provided in the readme file below.
  • For each function, you should have 2-3 test cases to confirm that your function really works.

Exercises:

  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]
  1. 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
  1. 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'!
  1. 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]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published