FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

Cycle

15mins

Implement a function that takes one or more values and returns a function. Every time you call the returned function, it should cycle through the provided values.

For example:

  • If you call cycle('hello'), the returned function will always return "hello".
  • If you call cycle('on', 'off'), the returned function will return "on" the first time, "off" the second time, then "on" again, and so on.

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests