Skip to content

Latest commit

 

History

History
21 lines (20 loc) · 370 Bytes

rotate.md

File metadata and controls

21 lines (20 loc) · 370 Bytes

Dynamically rotating the action

const actionMap = {
  step1() {
    console.log('step 1')
  },
  step2() {
    console.log('step 2')
  },
  step3() {
    console.log('step 3')
  }
}
const actions = Object.keys(actionMap)
for (let i = 0; i < 10; i += 1) {
  const action = actions[i % actions.length]
  // Rotate the action handling.
  actionMap[action]()
}