
previous

page 24
next
It took me a while to realise that the player's first click must be on a back because, at the start, that's all there is!
So I set up a variable like this:
var back_src='';
... and used the fact that it is empty at the start to recognise the first click - like this:
function card_clicked(image) {
if (back_src=='') {
back_src=image.src;
}
if (back_src=='') {
back_src=image.src;
}
So here's how I changed my program:
var back_src='';
function card_clicked(image) {
if (back_src=='') {
back_src=image.src;
}
if (image.src==back_src) {
...
}
}
function card_clicked(image) {
if (back_src=='') {
back_src=image.src;
}
if (image.src==back_src) {
...
}
}
previous
next