const timer = require('timers')
const lightList = ['red', 'blue']
const LIGHT = {};
const lights = 'lights';
for (const light of lightList) {
LIGHT[light] = `${lights} ${light}`
}
const lightAnyColor = ({light, nextLightFunc, lightTime}) => {
timer.setTimeout(() => {
console.log(light)
nextLightFunc();
}, lightTime);
}
const lightBlue = () => {
lightAnyColor({
light: LIGHT.blue,
nextLightFunc: lightRed,
lightTime: 1000,
})
}
const lightRed = () => {
lightAnyColor({
light: LIGHT.red,
nextLightFunc: lightBlue,
lightTime: 1000,
})
}
const start = () => {
lightRed();
}
start();
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
20