Javascript WorkFlow Series 2

Turning EVERYTHING into an Object

After all the functions work individually, I create a model object and turn all my variables and functions into object variables and object methods. The model object will take care of my app logic and calculation.

For example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//Before
var randomSeries = [];
var userInput = []

function game(){
if (isOn) {
reset();
}
}

//Now
var model = {
randomSeries: [],
userInput: [],
game: function() {
if (this.isOn) {
this.reset()
}
}
}

And test out the model object in console to make sure it works. If this part is complete we’re about 60% complete with our app. Here’s my draft 2 github