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
1. Name the first PC virus.<br> 2. In which language are viruses written for Microsoft programs?
Tju [1.3M]

Answer:

The first IBM PC virus in the "wild" was a boot sector virus dubbed (c)Brain, created in 1986 by Amjad Farooq Alvi and Basit Farooq Alvi in Lahore, Pakistan, reportedly to deter unauthorized copying of the software they had written. The first virus to specifically target Microsoft Windows, WinVir was discovered in April 1992, two years after the release of Windows 3.0.

Explanation:

HOPE THIS HELPS

6 0
3 years ago
Read 2 more answers
What is the trade-offs in time complexity between an ArrayList and a LinkedList?
AURORKA [14]

Answer:

  In the time complexity, the array-list can easily be accessible any type of element in the the given list in the fixed amount of time.

On the other hand, the linked list basically require that the list must be traversed from one position to another end position.

The Array-List can get to any component of the rundown in a similar measure of time if the file value is know, while the Linked-List requires the rundown to be crossed from one end or the other to arrive at a position.

4 0
3 years ago
Write a definition in your own words for Raster Graphic. Do not copy and paste please.
Vlada [557]

Answer:

Raster Graphic is a bitmap. They are basically a grid of small pixels that make an image.

6 0
3 years ago
Instructions
Reptile [31]

The assignment is about Telephone, internal combustion engine, and electrical light.

<h3>What is file?</h3>

A file is a  computer system container for storing data. Files used in computers are similar in characteristics to  paper documents used in libraries and office files. There are different types of files like text files, data files, folders, binary and graphic files and these different types of files store different types of data. A computer's operating system can store files  on optical discs, hard drives,  or other types of storage devices.

In most operating systems, a file must have a unique name within a specific directory. However, when creating a file name, some characters are considered illegal and therefore cannot be used. A file name consists of a name with an extension, also known as a file extension. The file extension is the two to four characters after the period of the full file name.

To learn more about file, refer;

brainly.com/question/29055526

#SPJ4

8 0
1 year ago
A potential customer wants to find out how blockchain can benefit their company and why they should use Accenture’s Multi-party
grandymaker [24]

Answer:

maybe blockchain can help them in term of security

6 0
3 years ago
Other questions:
  • Kurt is editing a table in his powerpoint that displays accounting formulas and when to use them. he wants to remove the table s
    15·1 answer
  • n macOS, what launch point provides access to almost all the settings needed to administer a macOS system?
    5·1 answer
  • Marty uses a customized database to sort parts and track inventory. The customized database is an example of _____.
    15·1 answer
  • Write a program that asks the user to enter the amount s/he has budgeted for a month. The amount should be between 1000 and 2000
    11·1 answer
  • The mods have peanuts for brains (it's true, I lost like 1k points to them for no reason)
    12·1 answer
  • . How to insert Section Break in Microsoft word 2016 ?
    14·1 answer
  • Apakah ada yang bisa menjelaskan potongan source code ini?
    15·1 answer
  • Introduction to computing systems: from bits and gates to c and beyond
    7·1 answer
  • Here is a nested loop example that graphically depicts an integer's magnitude by using asterisks, creating what is commonly call
    7·1 answer
  • State four features of information​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!