The purpose of this assignment is to help you understand how to work with conditionals, loops, and arrays in JavaScript.
1 . Add a files named arrays.html, arrays.css, and arrays.js to the appropriate directories in your csci230 directory.
2. In your arrays.html file add a heading that reads “Read the console”. Center this text both horizontally and vertically in the page.
3. In your arrays.js file add code that demonstrates the following:
- Create an array named list that contains the values 0,1,2,3,4,5,6,7,8, and 9.
- Use a for-in loop to print to the console the elements in the array named list.
- Use a for-of loop to print to the console the elements in the array named list.
- Use a for-loop to set all of the elements at even indices (0,2,4,6,8) in the array named list to 0.
- Print the contents of the array named list to the console as a single string.
- Print to the console the contents of the array named list as a single string with dashes (-) separating the elements.
- Add the number 7 to the beginning of the array named list.
- Remove the last element in the array named list.
- Print the contents of the array named list to the console as a single string.
- Print the length of the array named list to the console.
- Using the filter method, create an array named nonZero that contains the elements in the array list that are not zero.
- Print the contents of the array named nonZero to the console as a single string.
- Add 7, 8, and 9 to the end of the array named nonZero.
- Print the contents of the array named nonZero to the console as a single string.
- Reverse the order of the elements in the array named nonZero.
- Print the contents of the array named nonZero to the console as a single string.
- Sort the array in numeric order.
- Print the contents of the array named nonZero to the console as a single string.
© 2018 – 2021, Eric. All rights reserved.