Question: This is for a java script class, I need help with question 8 and 9. 1. (5 pts) Copy ALL of the contents in the
This is for a java script class, I need help with question 8 and 9.
1. (5 pts) Copy ALL of the contents in the public_html/csci2447/project2 folder into the public_html/csci2447/project3 folder. This ensures that you will not overwrite your work for the previous project. You will do this for each project from here on out. If you do not do this, there is no way for me to grade your previous project. 2. (5 pts) Remove the code previously added in Project 3 which shows the alert(). Only remove this line. Leave the ready() function. Type all of you code (except functions) in this ready function. 3. (5 pts) In the index.html file, find the line in div#gamespace that adds an image of the mole. Delete the entire img tag from div#gamespace. 4. (5 pts) The image for the mole resides in the img directory. In the jQuery ready function, write a line of Javascript/jQuery which dynamically adds the HTML for img tag (of the mole image) to the div#gamespace. Do not give it an id or class yet. 5. (5 pts) Add a line of jQuery code that shows the #timer. It will just appear now on load. This is because it is initially hidden upon start. In the next project, you will make its appearance dynamic! 6. (10 pts) Write two functions that generate random whole numbers. One function should return numbers between 0 and 300 (for the y positioning) and the other should return numbers between 0 and 600 (x positioning). Name them appropriately. Do not write these functions in the jQuery ready function. Write them just below it. You should test them to ensure they are working properly. Call them (temporarily) from the jQuery ready function and alert() the values. 7. (5 pts) In the jQuery ready function, write some Javascript/jQuery code which adds a jQuery click event listener to button#start_button. For the time being, add an alert() to test that the button click is working. 8. (5 pts) Create a function (outside the jQuery ready function) which increments the user's score when called and updates the HTML in span#score. Hint: You should create a global variable to keep track of the score. 9. (5 pts) Call your score increment function within Document Ready for testing purposes.
Below is the code that I have so far***************
var mole='';
var score = $('#score');
$(document).ready(function(){
$("#gamespace").html(mole);
$("#timer").show();
$("#start_button").click(myFunction);
function myFunction(){
alert("Okay");
alert(getX()+","+getY());
}; //end alert
}); //end.ready
function getY(min, max){
var y=Math.floor((Math.random()*300)+1);
return y;
}; //end y
function getX(min, max){
var x=Math.floor((Math.random()*600)+1);
return x;
}; //end x
function displayScore(){
score.innerHTML= ;
}; //end score
Whack-A-Mole
After clicking "start", you will have 30 seconds to click
as many moles as you can. The moles appear randomly so be ready!
0 pts
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
