11 Problem Set

  1. Reverse Array – Create a function reverseArray(arr) which takes an array as an argument. The function returns a new array with the values reversed. For example: reverseArray([1,2,3]) returns [3,2,1].
  2. Range Array – Create a function rangeArray(start, end) which takes two numbers as arguments. The function returns an array containing all the numbers from the start up to and including the end. For example: rangeArray(3, 9) returns [3,4,5,6,8,9].
  3. Longest Username – Create a function longestUser(ar) which takes an array of string values (usernames). The function returns the value of the longest username. For example: longestUser(["Tony", "Syeda", "Affroz", "Tatiana”]) returns "Tatiana".
  4. Only Numbers – Create a function onlyNums(arr) which takes an array as an argument. The function returns an array that has removed any values except numbers. For example: onlyNums(["fun", 23, 45, undefined, "a", 4]) returns [23, 45, 4].

Leave a comment

Your email address will not be published. Required fields are marked *