
previous

page 13
next
function cell_clicked(image) {
image.src='counters/1.png';
image.setAttribute('cn','1');
var arr=get_cns();
var score=worth(arr);
}
image.src='counters/1.png';
image.setAttribute('cn','1');
var arr=get_cns();
var score=worth(arr);
}
So where do we want that score to go? I think you'll agree that this is what we are after.
So that number will need to have an id so we can work with it.
I'm going to use the id s0.
Recall that it was produced by the one_row function.
Can you make the necessary change before looking at my answer?
document.write("<div id='s0'>0</div>");
Now I can finish cell_clicked:
function cell_clicked(image) {
image.src='counters/1.png';
image.setAttribute('cn','1');
var arr=get_cns();
var score=worth(arr);
var element=document.getElementById('s0');
element.textContent=score;
}
image.src='counters/1.png';
image.setAttribute('cn','1');
var arr=get_cns();
var score=worth(arr);
var element=document.getElementById('s0');
element.textContent=score;
}
Of course this won't work because we have yet to create the worth function. To check your work so far, create a worth function that just contains the line:
return 5;
previous
next