Skip to content

async debounce exercise 10  #27

Open
@ooddaa

Description

@ooddaa

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions