Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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. The code needs to have output. 1.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"]. 2.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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started