Question: Using HTML/JavaScript Arrays Array Literals Creating Arrays: Create and empty array named sabio.page.empty. Console log the length of the array. Create an array named sabio.page.myNumbers

Using HTML/JavaScript

Arrays

Array Literals

Creating Arrays:

Create and empty array named sabio.page.empty. Console log the length of the array.

Create an array named sabio.page.myNumbers which:

Must contain at least 4 members

All of them should be numbers

Accesing an Array Element:

Given the array sabio.page.pets = ['Fido', 'Chucho', 'Rocky', 'Drago','Precious'];

Console log the length of the array.

Console log the value of the element of index 1 of the array

Console log the value of the element of index 3 of the array

Adding an Array Element:

Given the array sabio.page.colors = ['Red', 'White', 'Black', 'Blue']; Use push() orunshift() to:

Add the color Yellow to the end of the sabio.page.colors array.

Add the color Green to the beginning of the sabio.page.colors array.

Combining Arrays:

Create a function named sabio.page.combine that will accept two arrays and combine both arrays.

Removing elements from an Array

Create a function named sabio.page.removeFirst that will accept an array. It should remove the first item from the array and return the item that was just removed. Use the shift() method to accomplish this.

Create a function named sabio.page.removeLast that will accept an array. It should remove the last item from the array and return the item that was just removed. Use the pop() method to accomplish this.

Create a function named sabio.page.removeThird that will accept an array. It should remove the element in the third index of the array and return the current arraywithout this element. Use the splice() method to accomplish this.

Array Enumeration

Create a function named sabio.page.calledInLoop that will accept one parameter and the function should console log the parameter.

Create a function named sabio.page.loopThrough that will accept an array.

Loop through each member of the array and invoke the function sabio.page.calledInLoop.

The result should be each element of the array console logged.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!