Crear una función debounce en JavaScript
function debounce(fn, delay) {
  let timer;
  return function() {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, arguments), delay);
  };
}
Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:

Crear una función debounce en JavaScript

### Response:

function debounce(fn, delay) {
  let timer;
  return function() {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, arguments), delay);
  };
}
