Question: please help with this: Linking JS File Go to the ja_vynes.html file. Directly above the closing tag, insert a script element that links the page
please help with this:
Linking JS File
Go to the ja_vynes.html file. Directly above the closing tag, insert a script element that links the page to the ja_quote.js file. Defer the loading of the script file until the rest of the page is loaded by the browser.
o to the ja_quote.js file in your editor. At the top of the file, insert a statement indicating that the code will be handled by the browser assuming strict usage.
Declare Function
Directly below the comment section, insert a function named randomIntthat will be used to generate a random integer. Specify two parameters for the function named lowest and size. The lowest parameter will specify the lowest possible value for the random integer and the size parameter will set the number of integers to be generated. Use those two parameter values and the Math.floor() and Math.random() methods to return a random integer within the specified range.
Call Function
Above the randomInt() function insert a command to call the function, generating a random integer from 0 to 9. (Hint: Remember that the size of this interval is 10 because it includes 0 in its range.) Store the result from the function in the randomQvariable.
Create a variable named quoteElemthat references the first element in the document that has the quote tag name.
Call the getQuote() function using the randomQ variable as the parameter value to generate a random Jane Austen quote. Display the text of the quote as the inner HTML code of the quoteElem variable.
COMMENT CODE
*******HTML FILE*********
/*
This script randomly generates a Jane Austen quote from
a list of 10 quotes and writes that quote into the first
quotation tag in the Web page.
*/
******JS FILE*********
function getQuote(n) {
var quotes = [
"It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.",
"I hate to hear you talk about all women as if they were fine ladies instead of rational creatures. None of us want to be in calm waters all our lives.",
"Silly things do cease to be silly if they are done by sensible people in an impudent way.",
"Give a girl an education and introduce her properly into the world, and ten to one but she has the means of settling well, without further expense to anybody.",
"Life seems but a quick succession of busy nothings.",
"Our scars make us know that our past was for real.",
"I cannot speak well enough to be unintelligible.",
"One cannot be always laughing at a man without now and then stumbling on something witty.",
"Men were put into the world to teach women the law of compromise.",
"The person, be it gentlemen or lady, who has not pleasure in a good novel, must be intolerably stupid."
];
return quotes[n];
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
