Random Customer Testimonial
Overview
In this assignment you'll use JavaScript to create a list of customer testimonials and display a random one on the page every time it loads.
Assignment
-
Create a new javascript file.
-
Correctly link that file to your Portfolio page using a
<script>
tag. -
Add an empty
<div>
tag to the bottom of the html page with a uniqueid
. -
In your JavaScript file, create an array of customer testimonials. Your testimonials must include quotation marks.
-
Create a separate function containing the necessary code to generate a random number between 0 and one less than the length of your array. (see below for a hint on creating random numbers in JavaScript)
-
Write the necessary code to call the function you created in step 5, then use that random number to selet a random testimonial from the array and place its text into the div you created in step 3.
-
Make sure your testimonial div is correctly styled with CSS to make it easily visible.
-
Update the table of contents link on your index page if necessary.
-
Submit the url to your github pages site to MySVU. (This should be something like https://USERNAME.github.io/REPOSITORYNAME).
Hints
-
You can find instructions on creating a random number in JavaScript here. (If you want additional details on how this works, see this StackOverflow link)
-
Remember, to include quotation marks in a string, you have to use the opposite kind of quotation marks to create the string:
var message = '"This is a quote..."';