Question: This assignment is related to the topic JavaScript. All problems require you to write simple JavaScript functions. The final result, whether it is a value,

This assignment is related to the topic "JavaScript". All problems require you to write simple JavaScript functions. The final result, whether it is a value, object, or function, should assign to a variable named myAnswer. The variable myAnswer need to be accessed by the system, it should NOT preceded by let nor var. You can press the "Test Run" button to test your program with a set of given test data. During the grading process of this assignment, additional test cases will be added to each question. 1. White a JavaScript function that accepts a positive integer, which is >2, and returns true if the input integer is a prime number and false otherwise. For this question, you have to pass the large majority of the test cases in order to obtain marks greater than 25%. 2.White a JavaScript function that accepts two 1D arrays of the same length and finds their sum of products as its return value. The sum of product is the sum of the products of the corresponding numbers in the two arrays. For example, if the two arrays are [1, 2, 5] and [1, 3, 2], then their sum of products is 1x1+2x3+5x2=17. You can assume that the length of the arrays is at least 1. 3.White a JavaScript function that accepts an object with two fields: data, and order. Both of them are 1D arrays of the same length. order contains the puermutation of the number 1 to n, where n is the length of data. The function should create and return an 1D array containing all value in data which are re-ordered according to order. For example, if the parameter is {data:["John","Peter","May"), order:[2,3,1]}, then, it means "John" should be in the 2nd position, "Peter" should be in the 3rd position, and "May" should be in the 1st position. Thus function should return the array ["May","John","Peter"). 4.By an n by n array, write a JavaScript to form and return a 1D array in which the elements are retrieved from the input 2D array in column-major order. For example, if the input array is [[1, 2], [3, 4]], then the return array is [1, 3, 2, 4]. Hint: you may use arr.push(v) to add the value v to an array arr
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
