Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

Explain basic scheduling concepts.

Answered: 1 week ago

Question

Question Can a Keogh plan fund be reached by the owners creditors?

Answered: 1 week ago

Question

Question What happens to my plan if I die?

Answered: 1 week ago