SteinarV Design's profile

Finite State Machine w. vanilla JavaScript

Finite State Machine example
Definition
The finite state machine can only have one single state active at the same time. This means that the machine has to transition from one state to another, in order to perform different actions.
Code excerpts
The state machine
Diagram of the machine
How to transition between states
The function createPanels( ) creates 5 buttons - Stop, Quote, Settings, Display and Start. Clicking one of these buttons will change the state of the machine. You can only click on buttons that are active. Active buttons are dependent of the state of the machine.
Codepen
"Codepen" - https://codepen.io/ - is a social development environment - an online code editor for developers of any skill - that allows people to write code in the browser, and see the results of it as they build. Codepen is particularly useful for people learning to code.
View the full code for the state machine at 
Here is a link to my blog : https://steinarv.design/blog
Thanks for watching !
Finite State Machine w. vanilla JavaScript
Published:

Owner

Finite State Machine w. vanilla JavaScript

Published: