Last active
September 12, 2020 18:13
-
-
Save jamiebullock/fc7b952c0cc98e8580b47a54eeeff9da to your computer and use it in GitHub Desktop.
Colour Jump Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stop = () => { console.log("stop called"); } | |
const go = () => { console.log("go called"); } | |
const colour = 'red'; | |
const handleColour = | |
{ | |
'red' : stop, | |
'amber' : stop, | |
'green' : go, | |
'flashing amber' : go | |
} | |
handleColour[colour](); // logs "stop called" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment