The following files exists in this folder. Click to view.
lab.md1 lines ASCII Unix (LF) Lab questions
==============================
// Create each one these questions in separate functions that returns the appropriate type.
// Use exercise.js to call the function and print out the result on separate lines.
1. Create an array with the length of 5 and holds the numbers 1, 2, 3, 4, 5. Name the function "myFirstArray" and print out the result.
2. Create an array that holds the sentence: "Hello! My name is John Doe". Each of the words should have an own spot in the array, meaning the array length should be 6. Name the function "arraySentence" and print out the result.
3. Pass an array of your choice to a function that returns a boolean (true/false) if the argument is an array or not. Name the function "checkArray" and print out the result.
4. Create a function that merges two arrays into a new array and return it. Name the function "concArrays" and print out the result.
5. Pass an array of your choice to a function and reverse the order of the elements. Name the function "reverseArray" and print out the result.
6. Create a function that takes two arguments, an array and a value in the array. The function should return the index in the array that the value is found at. For example, if the arguments are: [1, 2, 3] and 2, the function should return the index of 2, which in this case is 1. If the value does not exist in the array, it should return -1. Name the function "findIndex" and print out the result.
7. Pass an array of your choice to a function and use a "forEach-loop" to count the items in the array. Name the function "countArray" and return the result.
8. Pass an array of your choice and use a "forEach-loop" to add an "x" to all elements in the array. Name the function "changeArrayElements" and print out the result.
9. Pass an array of your choice to a function and join it into a string. Use a space (" ") to separate the elements. Name the function "joinArray" and print out the result.
10. Pass an array of your choice to a function that returns the last index of an element. Try an array with duplicates to see the result. Name the function "lastIndex" and print out the result.
11. Pass an array of your choice to a function and use "pop()" to remove the last element. Create a string that holds the array before you remove the element and after its removed. Also include the removed element. Return the string. Name the function "popArray" and print out the result.
12. Create a function that adds an element to an existing array. The function should take two arguments: an array of your choice and an element to add to it. Name the function "pushArray", return and print out the result.
13. Pass an array of your choice to a function and use "shift()" to remove the first element. Create a string that holds the array before you remove the element and after its removed. Also include the removed element. Return the string. Name the function "shiftArray" and print out the result.
14. Pass an array with numbers to a function that sort the array and returns it. Name the function "sortArray" and print out the result.
------------------------------
2014-06-03 (Zingo89) PA1 First try.