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
mars1129 [50]
3 years ago
5

Write a function named countEvens that counts and returns the number of even integers in an array. The function must have this h

eader: function countEvens(list) For example, if the countEvens function were called like this: var list = [ 17, 8, 9, 5, 20 ]; var count = countEvens(list); The countEvens function would return 2 because 8 and 20 are even integers.

Computers and Technology
1 answer:
skelet666 [1.2K]3 years ago
4 0

Answer:

function countEvens(list) {

   // IMPLEMENT THIS FUNCTION!

var even = [];

 

for(var i = 0; i < list.length; i++){

 if (list[i] % 2 == 0){

   even.push(list[i]);

   

 }

}

 return console.log(even)

}

var list = [ 17, 8, 9, 5, 20 ];

var count = countEvens(list);

Explanation:

The programming language used is JavaScript.

An even variable is initialized, to hold  the even variables within list.

A FOR loop loop iterates through all the elements in the list, an IF statement is used to check using the modulo division to check if the elements in the list are even.

The even elements are appended to the even list using .push() method.

Finally, the function returns the even list and outputs the list to the log using console.log(even) .

A list is created and the function is called.

You might be interested in
Steve is happy today but he ____ yesterday​
suter [353]

steve is happy today but he wasn't yesterday

3 0
3 years ago
Read 2 more answers
Which of the following tasks would least help an individual achieve a goal to safely lose weight?
ozzi
To continue to look at motivational or inspirational quotes to remind them or to remember how far you have come and it is not time to give up!
7 0
3 years ago
Read 2 more answers
Data values in a program are held in _________. a data types b names c variables d lockers
Tpy6a [65]

Answer:

Answered below

Explanation:

Data values in a program are held in variables. Variables are like containers for holding different types of data. A variable can be identified depending on the kind of data it holds. Variables can hold data types of integers, strings, arrays, lists, sets, Boolean etc. They hold unique data types and a can not hold different data types. Different rules exist for naming variables in different programming languages. A variable name should start with lowercase letters and be descriptive of the data it holds.

7 0
3 years ago
Which type of firewall policy calls for a firewall to deny all traffic by default?
charle [14.2K]
Restrictive policy is a kind of policy calls for a firewall to contradict all traffic by default. The first rule denies all traffic on any service and using any port. To permit a specific type of traffic, a new rule must be placed ahead of the deny all rule. A firewall should enforce the overall policy recognized by the network administrator. Enforcement is controlled mainly over setting up packet filtering rules which is a rule base comprises a set of these rules. 
3 0
3 years ago
Careful driving requires appropriate reaction time, both simple and complex. Braking and then shifting gears, followed by signal
QveST [7]
The correct answer is complex.
There are two types of reaction times when it comes to driving - simple and complex. Simple reaction time refers to your action after receiving some sort of a stimulus - when you see the red light, you are supposed to break. When it comes to complex reaction time, however, it has to do with your assessment of the situation, and realization what it is you have to do in order to avoid an accident, for example. 
4 0
4 years ago
Read 2 more answers
Other questions:
  • When you are shopping online and finalizing your order, you usually fill in forms for your name, address, email, and payment met
    6·1 answer
  • Which data type stores images and audio visual clips?
    9·2 answers
  • What will the following code display? #include using namespace std; void doSomething(int); int main() { int x{2}; cout &lt;&lt;
    9·1 answer
  • What portable computing devices, designed for user convenience, have a sensor called an accelerometer that senses vibrations and
    10·1 answer
  • A workstation with a static IP (Internet Protocol) address can print and authenticate to a server, but cannot browse to www.comp
    14·1 answer
  • What do people do when they navigate using GPS
    6·2 answers
  • Which of the following statements are true of
    14·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    9·1 answer
  • A continuous and differentiable function f(x) with the following properties: f(x) is decreasing at x=−5 f(x) has a local minimum
    13·1 answer
  • To read encrypted data, the recipient must decipher it into a readable form. What is the term for this process?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!