Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ We've been tasked with building out the behavior for a digital stopwatch, the in
####Directions
Spend 10 minutes looking at [JavaScript Timers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Timers), then check out the specific documentation for `setInterval` and `clearInterval`.

setImmediate()
Calls a function immediately after the browser has completed other operations, such as events and display updates.
clearTimeout()
Clears the delay set by setTimeout().
clearInterval()
Cancels repeated action which was set up using setInterval().
clearImmediate()
Cancels the immediate actions, just like clearTimeout() for setTimeout().


####Take It Step By Step

This is a tough assignment, so don't stress over meeting all the requirements. Just take it step by step and try to meet the benchmarks below in order.
This is a tough assignment, so don't stress over meeting all the requirements. Just take it step by step and try to meet the benchmarks below in order.

1. Create Javascript selectors that target each of the timer buttons.
2. Create click handlers (empty, for now) for each of the timer buttons.
Expand Down
36 changes: 36 additions & 0 deletions timers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
$(document).ready(function(){

let reset = $(".controls").find("#reset");
let start = $(".controls").find("#start");
let pause = $(".controls").find("#pause");

console.log(reset, start, pause);
///set the variables
let seconds = 0;
let timerId = 0;
let timer;

///set the click events and what happens inside them

//reset button
$(reset).on('click', function(){
console.log("reset");
clearInterval(timer);
seconds = 0;
$('#timer').html(seconds);
});
//start buttom
$(start).on('click', function(){
console.log("start");
timer = window.setInterval(updateTime, 1000);
console.log(seconds)
});
//pause button
$(pause).on('click', function(){
console.log("pause");
clearInterval(timer);
});

//update time function
updateTime = function(){
$('#timer').html(seconds);
seconds = seconds+1;
};

});////END OF DOCUMENT READY