DEV Community

loading...

Discussion on: A JavaScript interview question asked at Facebook

Collapse
gixxerblade profile image
Steve Clark 🤷‍♀️

This is what I got.

let animate = (el, milliseconds, distance) => {
  let element = document.getElementById(el);
  element.setAttribute(
    "style",
    `transform:translateX(${distance}px); transition-duration: ${milliseconds}ms;`
  );
};
animate("para", 2000, 500);```