Exercises

Estimated reading: 1 minute 109 views

Create an Array: Declare an array named fruits containing the names of three fruits.

Access Array Elements: Access and print the second element of the fruits array.

Modify Array Element: Replace the second element of the fruits array with “grape”.

 

Add Array Element: Add “kiwi” to the end of the fruits array.

 
 

Remove Array Element: Remove the first element from the fruits array.

 

Array Length: Print the length of the fruits array.

 

Check if an Element Exists: Check if “orange” exists in the fruits array.

 
 

Sort Array: Sort the fruits array in alphabetical order.

 
Share this Doc

Exercises

Or copy link