Array Methods Exercise

Create a new JavaScript file and put these two arrays at the beginning. You will perform operations with them.

var fruit = ["banana", "apple", "orange", "watermelon"];
var vegetables = ["carrot", "tomato", "pepper", "lettuce"];

After every command, console.log() your arrays. A good way to do that is to use:

console.log("fruit: ", fruit);
console.log("vegetables: ", vegetables);
  1. Remove the last item from the vegetable array.
  2. Remove the first item from the fruit array.
  3. Find the index of "orange."
  4. Add that number to the end of the fruit array.
  5. Use the length property to find the length of the vegetable array. Log that to the console.
  6. Add that number to the end of the vegetable array.
  7. Put the two arrays together into one array. Fruit first. Call the new Array "food".
  8. Remove 2 elements from your new array starting at index 4 with one method.
  9. Reverse your array.
  10. Log your array as a string to the console.

If you've done everything correctly, the last step should print the following to the console: