Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async debounce exercise 10 #27

Open
ooddaa opened this issue Jun 9, 2024 · 0 comments
Open

async debounce exercise 10 #27

ooddaa opened this issue Jun 9, 2024 · 0 comments

Comments

@ooddaa
Copy link

ooddaa commented Jun 9, 2024

Hey!

In the solution this line is

setTimeout(function() { console.log(giveHiSometimes()); }, 4000); // -> 'hi'

whilst in the original course task file it's

setTimeout(function() { console.log(giveHiSometimes()); }, 4000); // -> undefined

Therefore the solution works for the variant from the repo and does not work for the variant in the course task file.

The code below works for the task file variant, but does not work for the solution variant 😂

function debounce(callback, interval) {
  let lastCall; 
  
  return () => {
    const thisCall = new Date().valueOf()
    const cond = !lastCall || thisCall > (lastCall + interval)
    lastCall = thisCall
    if (cond) return callback()
  }
}

What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant