




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Quick explanation: Math.random() generates a random number between 0 and 1 (e.g., 0.4). We multiply this by a range to generate a random number between 0 ...
Typology: Summaries
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Quick explanation:
Our first javascript!
New Text Goes Here
Exercise 2: Modify your web page so that it includes a counter for each image on the page and displays a count of how many
Comments:
Every programming language allows people to include comments to themselves and to other people using
comments. Comments start with /* and end with */. Everything between these opening and closing markers is
ignored by the browser, so anything between them won’t run in javascript.
Here’s an example of a comment:
function TextRandPic(par1, par2) { /* This function takes two parameters. The first must hold the id of something with text (e.g., a paragraph, a header, etc., and the second parameter holds the id of an image on your web page. The function checks to see which image you clicked on based on the id in the second parameter, and changes the innerHTML of the text element (using the id in the first parameter). It then displays two new random pictures. */ if (par2 == "pic1") { counter1 = counter1 + 1 document.getElementById(par1).innerHTML = "You picked the first picture!" } else if (par2 == "pic2") { counter2 = counter2 + 1 document.getElementById(par1).innerHTML = "You picked the second picture!" } randnum = Math.floor(Math.random() * imgArray.length) document.images["pic1"].src = imgArray[randnum] randnum = Math.floor(Math.random() * imgArray.length) document.images["pic2"].src = imgArray[randnum] }
...
Here’s an idea!
Here’s another idea!
Here’s another idea!
Here’s another idea!
Click here for more healthy living instructions!To turn in:
Extra Info:
Our first javascript!
** Your Choice!
** This is the first paragraph on the page
** This is another paragraph. ** link
Click here for new link