Question: Complete the JavaScript (wks1.js) and Python (wks1.py) code for the following questions: Create a function called generateEven that will return array containing only even numbers
Complete the JavaScript (wks1.js) and Python (wks1.py) code for the following questions: Create a function called "generateEven" that will return array containing only even numbers between 1 and n. n is passed as a parameter to the function. 1. 2. Write a function called "getSize" that accepts an array and display the number of elements in an array (list) 3. Write a function called "isEven" that accepts a value and returns true if value is even and false otherwise 5. Write a function called "addTo" that will add a value to an array based on the position specified. The function will accept three parameters, the array of values, the value to be entered, and a string which identifies the position. The positions can be either 'front' or "back'. Invalid position values should throw an exception with an appropriate message. You are expected to use the appropriate methods of the array (list). 6. Write a function called "enqueue", that will perform the enqueue operation on an array. The array and the value to be enqueued is supplied through a parameter. 8. Write a function called "sortNumArrAsc" that will sort an array of integers in ascending order. 9. Write a function called "sortStringArrDesc" that will sort an array of strings in descending order 10. Write a function called "sortNamesBySurnameAsc" that will receive an array of names by surname then first name. For Example: Input: Robert SmithOutput: Maria Garcia Maria Garcia' David Smith Maria Rodriguez Maria Rodriguez David Smith Robert Smith Complete the JavaScript (wks1.js) and Python (wks1.py) code for the following questions: Create a function called "generateEven" that will return array containing only even numbers between 1 and n. n is passed as a parameter to the function. 1. 2. Write a function called "getSize" that accepts an array and display the number of elements in an array (list) 3. Write a function called "isEven" that accepts a value and returns true if value is even and false otherwise 5. Write a function called "addTo" that will add a value to an array based on the position specified. The function will accept three parameters, the array of values, the value to be entered, and a string which identifies the position. The positions can be either 'front' or "back'. Invalid position values should throw an exception with an appropriate message. You are expected to use the appropriate methods of the array (list). 6. Write a function called "enqueue", that will perform the enqueue operation on an array. The array and the value to be enqueued is supplied through a parameter. 8. Write a function called "sortNumArrAsc" that will sort an array of integers in ascending order. 9. Write a function called "sortStringArrDesc" that will sort an array of strings in descending order 10. Write a function called "sortNamesBySurnameAsc" that will receive an array of names by surname then first name. For Example: Input: Robert SmithOutput: Maria Garcia Maria Garcia' David Smith Maria Rodriguez Maria Rodriguez David Smith Robert Smith
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
