And we’ll write some code to compare the player’s square’s indices against all of the possible winning layouts.
We have a function userWins which calculates all the player’s indices and intersects them with all the possible winning rows.
Basically, if the intersection returns 3 values then the game has been won.

App.IndexController=Ember.ArrayController.extend({//...selectBox:function(box){if(box.get('selected')){return;}box.set('userSelected',true);if(this.userWins()){this._notify("Congratulations. You beat a random number generator");}elseif(!this.get('unselectedContent').length){this._notify("A draw? Is that the best you can do");}else{this.performMove();}},performMove:function(){varavailable=this.get('unselectedContent');varselected=this.selectMove();available[selected].set('computerSelected',true);if(this.computerWins()){this._notify("Ouch. You lost to a random number generator");}},_notify:function(msg){Ember.run.next(function(){alert(msg);});}//...})

The next step would be to make the UI a little smarter, I would probably check for any intersections that return two
matches and see if the missing index is still empty, but I’ll leave that as an exercise for the reader.

Have a great day, now go building something utterly useless and let me know @bradleypriest