Advertisement
3vo

One-dimensional Arrays

3vo
Apr 4th, 2023
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.70 KB | Software | 0 0
  1. /*
  2. One-dimensional Arrays
  3. Given the following array:
  4.  
  5. const arr = [2, 1, 3, 4, 6, 0, 0, 5, 7, 8, 10];
  6. Try to:
  7.  
  8. Reverse the array.
  9. Create a new copy of the array using the built-in array methods.
  10. Return true or false whether 10 is in the array.
  11. Return the first number that is greater than 6.
  12. Remove any duplicate numbers from the array.
  13. Flatten the array using a built-in array method. For example:
  14.  
  15. // Transform this multidimensional array
  16. const arr = [1, 2, [3, 4, [5, 6]]];
  17. // into this one-dimensional array [1, 2, 3, 4, 5, 6];
  18. Return the most frequently occurring number in the array. Use the following to test your solution:
  19.  
  20. const arr = [1, 2, 1, 4, 2, 4, 2, 3, 3, 5, 6, 7, 3, 2];
  21. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement