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
Eva8 [605]
3 years ago
12

Write a setInterval() function that increases the count by 1 and displays the new count in counterElement every 300 milliseconds

. Call clearInterval() to cancel the interval when the count displays 5.
var count = 0;


var counterElement = document.getElementById("counter");


counterElement.innerHTML = count;



/* Your solution goes here*/
Computers and Technology
1 answer:
Alina [70]3 years ago
8 0

Answer:

  1. var count = 0;
  2. var counterElement = document.getElementById("counter");
  3. counterElement.innerHTML = count;
  4. var a = setInterval(
  5.    function(){  
  6.        count++;
  7.        counterElement.innerHTML = count;
  8.        if(count == 5){
  9.            clearInterval(a);
  10.        }
  11.    }
  12.        , 300);

Explanation:

The solution code is given from Line 6 - 15.  

setInterval function is a function that will repeatedly call its inner function for an interval of time. This function will take two input, an inner function and the interval time in milliseconds.  

In this case, we define an inner function that will increment count by one (Line 8) and then display it to html page (Line 9). This inner function will repeatedly be called for 300 milliseconds. When the count reaches 5, use clearInterval to stop the innerFunction from running (Line 11 - 13).  

You might be interested in
What does FTTB mean?
EleoNora [17]

  • <em><u>Fiber to the building</u></em>

Explanation:

  • <em><u>Fiber to the building</u></em><em><u> </u></em><em>is a type of fiber-optic cable installation where the fiber cable goes to a point on a shared property and the other cabling provides the connection to single homes, offices or other spaces.</em>

<h2><em>hope </em><em>it</em><em> helps</em><em>!</em></h2>
3 0
2 years ago
Hi there! I am writing a code to make a square using a drone, however I’m having trouble doing so. The website that I’m writing
Jlenok [28]

Answer:

i might

Explanation:

3 0
2 years ago
Assume you want to write a code to calculate the addition of two numbers digit by digit. Provide the running time for your algor
Sergio039 [100]

Answer:

Explanation:

Using Python programming language

Explanation:

1. I defined a function add and passed in two parameters (a,b).

2. In the block of the function, I added the two numbers and printed the result.

3. I decided to use a function so that the program is re-usable and can accept various inputs.

Find the code below. (# are used for comments)

#Addition of numbers

def add(a,b):

   print(a+b)

#Test Cases

add(2,4.5)      #Result=6.5

add(10,290)     #Result=300

add(2.567,4.58) #Result=7.147

5 0
2 years ago
1. A green traffic sign means
NeX [460]

Answer:

general regulatory and speed control.

7 0
3 years ago
Given the following MIPS Code Fragment:
galben [10]

Answer:

There are 3 Data Hazard

Explanation:

Find attached the solution

6 0
3 years ago
Other questions:
  • The two types of objects responsible for collecting data are
    14·1 answer
  • Let's say you're creating a search stream in your hootsuite dashboard, to find mentions of the phrase vacation holiday getaway.
    15·1 answer
  • Instructions:Type the correct answer in the box. Spell all words correctly.
    14·2 answers
  • Approximately what percent of desktop PCs are used for work-related purposes?
    12·1 answer
  • Which is not an example of a mobile operating system?
    9·1 answer
  • Circular error are caused by adding the cell name of a/an cell to aformula
    7·1 answer
  • You can combine the algorithms for converting between infix to postfix and for evaluating postfix to evaluate an infix expressio
    13·1 answer
  • BUURTAIS
    7·1 answer
  • What function is used to return the results in column D?
    11·1 answer
  • A data table is a range that displays what?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!