JS Coding Challenge #1 — Test your skills 🤔

Kitze
1 min readMay 28, 2016

--

Hey hey! Here’s the deal. I was trying to recreate the “OK Google” microphone animation with CSS3 animations + aphrodite, and in React i was managing the animation state like this.

As you can see, this isn’t the prettiest sight for the eyes, it doesn’t look clean at all, and the syntax is a bit difficult to follow.

So i decided to write a function that should accept an array of functions and integers. The functions should execute, and on the integers the flow should pause for x milliseconds, and then execute the next function. It should be called like this.

How would you write the sequence function?

📜 Rules

  • You can use ES6 or lodash
  • Write it as a GitHub gist, or post it on jsfiddle, codepen, jsbin, etc. and paste the link in the comments, or send it to me on twitter.
  • (hint): the this.setState function returns “undefined” so try to use that somehow 😉

🙊 Spoiler alert!

I have already solved it with a 1 liner, but try to write your own solution before you take a sneak peek!

🤓 Have fun and follow me @thekitze where i ramble about JS, React, Redux, MobX etc.

--

--