Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
442 B
6
Indexable
Never
var time = [];

var counter = 1;

var eightSeconds = setTimeout(function() {
    console.log(time)
}, 8 * 1000);

var add = setInterval(function(){
    time.push(counter);
    console.log(counter)
    if(time.length > 15){
        clearInterval(add);
        console.log(sum());
    }
    counter++;
}, 1000);



function sum(){
    var total = 0

    time.forEach(function(element){
    total += element
    });
}