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
zheka24 [161]
3 years ago
6

Function _one(array)

Computers and Technology
1 answer:
dsp733 years ago
6 0

Answer:

function removeRepeaters(list){

   var goodList = [], badList = {}, used = {}, n;

   // ensure that the argument is indeed an array

   if(!Array.isArray(list)){

        throw "removeRepeaters: Expecting one argument of type Array";

   }

   // loop through the array and take note of any duplicates

   for(n in list) used[list[n]] == true ? badList[list[n]] = true : used[list[n]] = true;

   // now loop through again, and assemble a list of non-duplicates

   for(n in list) if(badList[list[n]] == undefined) goodList[] = list[n];

   return goodList;

}

Explanation:

I assume you're familiar with trinary operators, but just in case, that's what's happening in this first for loop:

for(n in list) used[list[n]] == true ? badList[list[n]] = true : used[list[n]] = true;

this is the same as saying:

for(n in list){

   if(used[list[n]] == true){

       badList[list[n]] = true;

   } else {

       used[list[n]] = true;

   }

}

This loop flags all of the values in the list that are duplicated.  Note that both "badList" and "used" are declared as objects instead of arrays.  This allows us to compare keys in them with an == operator, even if they're not defined, making it a convenient way to flag things.

Note that I haven't tested it, so I may have overlooked something.  I suggest testing it before handing it in.

You might be interested in
La estructura basica de una pagina web en Html​
Musya8 [376]

Answer:

<!doctype html>

<html>

<head>

<title>

</title>

</head>

<body>

</body>

</html>

Explanation:

Esta estructura básica se conoce como esqueleto.

5 0
2 years ago
KELLY Connect
Natalija [7]

Answer:

I believe that would be Microsoft Windows Task Manager

Explanation:

3 0
2 years ago
A palindrome is a string that reads the same both forward and backward. For example, the string madam is a palindrome. Write a p
miskamm [114]

Answer:

Explanation: Hey bro! Sorry to bother. But have any of your questions got deleted after posting them? I don't know why my question got deleted by a guy.

8 0
3 years ago
Which statement describes what this command accomplishes when inside and outside interfaces are correctly identified for NAT? ip
Marianna [84]

Answer:

The answer is "Option C".

Explanation:

The NAT accurately identifies the environment and internal interfaces, and main customers can link to a 192.168.1.50 Web server. When designed for, proxies examine input and output packages. IP nat "inside source" implies to encourage an outgoing parcel emanating from an "outside" application and behave accordingly.

7 0
2 years ago
Your team at amazon is overseeing the design of a new high-efficiency data center at hq2. a power grid need to be generated for
elixir [45]

Answer:

void print2(int row) {

for (int i = 0; i < row; i++) {

 char ch = 'a';

 char print = ch;

 for (int j = 0; j <= i; j++) {

  cout << print++;

 }

 cout << endl;

}

}

int count_digits(int num) {

int count = 0;

int temp = num;

while (temp != 0) {

 temp = temp / 10;

 count++;

}

return (num % count);

}

Explanation:

3 0
2 years ago
Other questions:
  • Why is knowledge of percent composition important in the mining process?
    7·1 answer
  • HELP I don't understand this
    14·2 answers
  • Please help will mark brainiest
    8·1 answer
  • Smart art can be used to create _____that highlights relationships betweeen two items
    8·2 answers
  • Which of these networks is primarily for posting and viewing photos?
    8·2 answers
  • What are the differences in LAN and WAN and how they are used to Increase Cybersecurity
    7·1 answer
  • Power point presentation make use of pages known as
    9·2 answers
  • How are Earth's plates made?
    14·1 answer
  • Whats 12/29 divided by 12/34
    7·2 answers
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!