1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
RoseWind [281]
2 years ago
11

Write syntactically correct Javascript code to sort an array of sub-arrays containing integers using the sort and reduce array f

unctions as described below. You will sort the sub-arrays in ascending order by the maximum value found in each sub-array. Your solution would be executed in the following manner:
Computers and Technology
1 answer:
masha68 [24]2 years ago
3 0

The question is incomplete. The complete question is:

Write syntactically correct Javascript code to sort an array of sub-arrays containing integers using the sort and reduce array functions as described below. You will sort the sub-arrays in ascending order by the maxium value found in each sub-array. Your solution would be executed in the following manner:

var x = [ [ 2 , 5 , 1 ], [ 1 , 23 ] , [ 3 ] , [ 22, 16, 8 ] ] ;

x.sort(compare);

will result in variable x containing [ 3 ] , [ 2, 5, 1], [ 22 , 16 , 8], [ 1 , 23 ] ]. The maximum value of each sub-array is shown here in bold. Your solution must be written so that when run with the code above, x will contain the sorted array.

Answer:

function compare(a , b) {

var max1 = Math.max(...a); //get the max in array a

var max2 = Math.max(...b); //get the max in array b

return max1 - max2;

}

var x = [ [ 2 , 5 , 1 ], [ 1 , 23 ] , [ 3 ] , [ 22, 16, 8 ] ] ;

x.sort(compare);

Explanation:

Given an array A positive integers, sort the array in ascending order such that element in given subarray which start and end indexes are input in unsorted array stay unmoved and all other elements are sorted.

An array is a special kind of object. With the square brackets, access to a property arr[0] actually come from the object syntax. This is essentially the same as obj[key], where arr is the object, while numbers are used as keys.

Therefore, sorting sub-array in ascending order by the maxium value found in each sub-array is done:

function compare(a , b) {

var max1 = Math.max(...a); //get the max in array a

var max2 = Math.max(...b); //get the max in array b

return max1 - max2;

}

var x = [ [ 2 , 5 , 1 ], [ 1 , 23 ] , [ 3 ] , [ 22, 16, 8 ] ] ;

x.sort(compare);

You might be interested in
Match the spacing options to their meanings.
Maslowich

Before text = indents paragraph to the right  

First line = indents the start of a paragraph

Register-true = formats page styles  

Line spacing = manages space between two lines  

The first line always gets indent to specify that it is a start of the paragraph

Line spacing always focus on the number of spaces between lines. There are various values available to give spacing according to the need. Register- true is used to format all the page styles and do other related configurations.

3 0
2 years ago
Read 2 more answers
True or false windows 98 and windows xp are examples of an operating system?
rodikova [14]

Answer:

true

Explanation:

3 0
2 years ago
A user complains because the social media apps on his mobile device always note his location. The user is worried about privacy,
stich3 [128]

Answer:

Geotracking feature needs to be adjusted.

Explanation:

5 0
2 years ago
What is this <br>name which console it is ​
ZanzabumX [31]

Answer:

ps3

Explanation:

becaus with is and I'm right

6 0
2 years ago
Read 2 more answers
You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
svetlana [45]

Answer:

Explanation:

Network Access Control is needed to make sure that only set of verified users access the network.

It makes sure that the users are authenticated and only set of some verified users have access to network.

Set of NAC solutions like Impulse SafeConnect, Extreme Networks, ExtremeControl, Auconet BICS, ForeScout CounterACT, Pulse Policy Secure could be installed in the system which along with basic profiling will make sure authenticated access to the network.

Other than this basic encryption-decryption algorithm can be used in this regard. Network components could use encryption algorithms like RSA and DES. These algorithms will make sure that the information from database side is well encrypted. Once that information goes to the network component. They can decrypt the encryption by generating relevant key using the same algorithm.

This will only allow authentic users to access information and also it will stop the leakage of information in between the transmission because of encryption.

4 0
3 years ago
Other questions:
  • Regulatory control limits the activities of an organization in compliance with the organization's policies. True False
    14·2 answers
  • _____ software can help a company manage security, enforce corporate strategies, and control downloads and content streaming fro
    11·1 answer
  • Select all statements that correctly describe the ramifications of important features supported by modern DBMS.
    15·1 answer
  • During the charging of a storage battery, what is the temperature that the electrolyte solution must never exceed?
    6·1 answer
  • Consider the following definition of a recursive method. public static int mystery(int[] list, int first, int last) { if (first
    7·1 answer
  • Name similarities between innovation and invention
    6·1 answer
  • What is an Algorithm? (might not be in the chapter text). Give an example.
    13·1 answer
  • 22. Which of the following device will you require to hear music on
    5·1 answer
  • Select all correct statements below: Group of answer choices A redundant link's switch port will be blocked by STP until needed.
    6·1 answer
  • ____ the most popular word processing applications software<br><br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!