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
How many tens are there in the number 156?<br> A. 1<br> B. 15<br> C. 6<br> D. 56
dexar [7]

Answer:

15

Explanation:

15 times 10 is 150, therefore there is 15 tens inside 156.

7 0
3 years ago
Read 2 more answers
Students at a university are working on a project. the project involves many computing systems working together on disjointed ta
skad [1K]
I think that the form of computing the project would be using is CLUSTER COMPUTING.

It involves a group of linked computers working together that it forms, in essence, a single computer. In this way, each user can work on his or her own tasks all at the same time. This will improve performance, increase output, and it is more cost-effective than using a single computer for the whole project.
8 0
3 years ago
Read 2 more answers
A is a program for editing,rearranging and storing text
UNO [17]

Answer:

text editor

Explanation:

hope it helps

4 0
3 years ago
Read 2 more answers
Please help me please i’ll give brainli
DaniilM [7]
Answer: a digital bulletin board
4 0
3 years ago
While adding voices to an animation, what kind of room should you choose?
MrRissso [65]

Answer:

A. A quiet room

Explanation:

Because if you open the windows the will be noise

a huge room will echoe

a room with air conditioning will make noise

7 0
3 years ago
Other questions:
  • To change the caption for a field in a query, click the field in the design grid, click the ____ button on the Design tab, click
    14·1 answer
  • Let’s say you are given a number, a, and you want to find its square root. One way to do that is to start with a very rough gues
    15·1 answer
  • PLS ANSWER QUICK!!!!
    12·1 answer
  • Boardman College maintains two files—one for Sociology majors and another for Anthropology majors. Each file contains students'
    5·1 answer
  • Arrange the types of movies in terms of the amount of content they can hold
    14·1 answer
  • Write the simulate method, which simulates the frog attempting to hop in a straight line to a goal from the frog's starting posi
    10·1 answer
  • Which one of the following does NOT contain a
    9·2 answers
  • POINT BOOST:
    12·1 answer
  • Which of the following is an example of effective nonverbal communication?
    8·1 answer
  • In which directory would a system administrator store scripts that should be run monthly by the cron daemon?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!