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]
2 years ago
6

Function _one(array)

Computers and Technology
1 answer:
dsp732 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
What is the oldest malware victor
arsen [322]

Answer:

The oldest malware vector was emails.

Explanation:

Websites were not widespread early on into the internet, however it was very easy to have a virus that uses an email contact list, where it can send itself to other email addresses and spread.

7 0
3 years ago
Qué propiedades del bromato de potasio han hecho que sea el aditivo más usado en la fabricación del pan​
torisob [31]

Answer:

es la capacidad de unir proteínas presentes en la harina

4 0
3 years ago
The Chairman of the Federal Reserve & the Federal Open Market Committee determine the percentage of a deposit which must be
Scrat [10]
Required Deposit Reserve
6 0
3 years ago
Which form of media allows the audience to share in and comment on the content immediatly
Luba_88 [7]

twitter

they will allow you to share comments about any topic you want

4 0
3 years ago
Information​ technology, especially the use of​ networks, can help firms lower the cost of​ ________, making it worthwhile for f
aniked [119]

Answer:

MARKET PARTICIPATION.

Explanation:

<em>Because this way the firm size can stay constant or contract even if the company increases its revenues. Information technology helps firms contract in size because it can reduce transactions costs. According to the transaction cost theory, firms and individuals seek to economize on transaction costs, much as they do on prodcution costs. For instance, by using computer links to external suppliers, the Chrylser Corporation can achieve economies by obtaining more than 70 percent of its parts from other companies.</em>

5 0
3 years ago
Other questions:
  • Universal Containers has a requirement to integrate Salesforce with an external system to control record access.
    12·1 answer
  • Sql is an example of a ________ category programming language. 4gl 3gl 5gl 2gl
    15·1 answer
  • What is the difference, if any, between an alpha test group and a beta test group? An alpha test group is made up of people asso
    9·1 answer
  • Compare entertainment applications to social media applications.
    5·2 answers
  • What is “GoF” and how does it relate to design patterns?
    7·1 answer
  • Cuáles eran las condiciones de vida de las mujeres durante el renacimiento perduran​
    14·1 answer
  • Which one way in which using infrared in game console controllers could affect the experience of a person playing the game?
    8·1 answer
  • Which statement about intellectual property is true? (CSI-7.6) Group of answer choices It is okay to use code you find on the in
    14·1 answer
  • Group of programs are software ​
    6·2 answers
  • You have a Windows system that has both wired and wireless network connections. The wired connection is on the internal private
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!