QUIZ
Code Explanation
document.f.score.value = "0"; Set score to 0
return false; This is done to prevent an HTML reloading of the page
} Close setupgame function
function pickelement(ev) { Start of pickelement function
var thisx; Variable to hold the horizontal position of this element
(the element that received the click event)
var thisxn; Variable to hold the number represented by thisx, which
is text
if (makingmove) { Is this a second click?
thisx= this.style.left; Set thisx
thisx = thisx.substring
(0,thisx.length-2);
Remove the px from the string.
thisxn =
Number(thisx) + 110;
Turn this into a number and then add fudge factor to
position the element first clicked to the right of this
element
elementinmotion.style.left =
String(thisxn)+"px";
elementinmotion holds the first click element. position
it horizontally to the calculated thisxn value.
elementinmotion.style.top =
this.style.top;
Position it vertically the same as the this element
makingmove = false; Set makingmove back to false
if (this.id.substring(1)==
elementinmotion.id.substring(1)) {
Check if this is a match by comparing the ids, after using
substring to leave off the first character
elementinmotion.style.
backgroundColor = "gold";
If it was a match, change the color of elementinmotion
and
this.style.backgroundColor = "gold"; this element
document.f.out.value = "RIGHT"; Output the value RIGHT