Howdy
first or Partnah
first?
delayedGreet
that console logs welcome
after 3 seconds.
helloGoodbye
that console logs hello
right away, and good bye
after 2 seconds.
brokenRecord
that console logs hi again
every second. Use the End Code
button to stop the console logs when you are satisfied that it is working.
limitedRepeat
that console logs hi for now
every second, but only for 5 seconds. Research how to use clearInterval
if you are not sure how to do this.
Write a function called everyXsecsForYsecs
that will accept three arguments: a function func
, a number interval
, and another number duration
.
everyXsecsForYsecs
will execute the given function every interval
number of milliseconds, but then automatically stop after duration
milliseconds.
Then pass the below sayHi
function into an invocation of everyXsecsForYsecs
with 1000 interval time an 5000 duration time.
What do you expect to happen?
Write a function delayCounter
that accepts a number (called 'target') as the first argument and a number of
milliseconds (called 'wait') as the second argument, and returns a function.
When the returned function is invoked, it should log to the console all of the numbers between 1 and the target number, spaced apart by 'wait' milliseconds.
Write a function, promised
, that takes in a value. This function will return a promise that will resolve after 2 seconds.
Hint: take a look at the Promise object docs on MDN.
SecondClock
class, with two methods: start
and reset
.
start: upon invocation, invokes a callback (this.cb, defined in the constructor) on an argument every second, with the argument to the callback being the current seconds "value".
In other words, the callback gets invoked every second on the "seconds hand" of the clock. Always start with 1 and don't utilize the seconds value of the current computer clock time.
reset: upon invocation, completely stops the "clock".
Also resets the time back to the beginning.
Hint: look up setInterval
and clearInterval
.
Write a function called debounce
that accepts a function and returns a new function that only allows invocation of the given function after interval
milliseconds have passed since the last time the returned function ran.
Additional calls to the returned function within the interval
time should not be invoked or queued, but the timer should still get reset.
For examples of debouncing, check out https://css-tricks.com/debouncing-throttling-explained-examples/