

page 12
So how did you go?
We need to work out the score for the row after the player adds a counter to the grid by clicking a cell so that line has to go into cell_clicked.js.
image.src='counters/1.png';
image.setAttribute('cn','1');
var arr=get_cns();
}
And did you remember to add this line to the head section of index.html?
I hope you've carefully dealt with all the new stuff. I also hope that you tried your new index.html, clicked on some cells and observed that nothing seemed to happen except for the red counters appearing.
And that is at it should be because, although we hope the array [1,0,1,1,0] has been created, we haven't done anything with it. And what has to be done with it? We have to work out that it's three of a kind and so is worth 5 points.
So we'll need a new function to do this for us. Let's call it worth. We'll pass it the array arr and expect a number to be returned.
image.src='counters/1.png';
image.setAttribute('cn','1');
var arr=get_cns();
var score=worth(arr);
}