Check out a free preview of the full State Machines in JavaScript with XState course:
The "Refactoring with XState Exercise" Lesson is part of the full, State Machines in JavaScript with XState course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to refactor the code from the state machine execise in section 2 using XState.

Get Unlimited Access Now

Transcript from the "Refactoring with XState Exercise" Lesson

[00:00:00]
>> In case you wanna do exercise two, in order to get more of a feel for Xstate, you could take your object syntax that you had over here in exercise one, copy that over inside of createMachine. And so, if you recall, it's the exact same syntax and then we're going to be setting our currentStates to machine.initial.

[00:00:27] And then our send is just going to be currentState is the machine.transition, the currentState and the events. And so this is going to be how we use XState in order to do the exact same thing that we did in exercise one. So exercise three encompasses both exercise two and using an interpreter.

[00:00:58] So we're just mushing those into one exercise.