Thursday, January 9, 2020

Lab 8 Random Testimonials Troubleshooting

In this lab, I fixed the website that was given to me via a zip file. First up, downloaded and opened up the zip file. Next I looked through the code to see if there was any errors like missing semicolons or wierd syntaxes. Then I noticed that the multiple texts did no change right below the top image. So I typed in <script> tags to link my JavaScript file to the HTML file to make the text change. I typed into the JavaScript:
$(function(){
"use strict";
var pressQuotes = [];
pressQuotes[0]="NAPS is by far the most significant cultural force of the decade. — New York Times";
pressQuotes[1]="These days sleeping at your desk is not just acceptable, it's encouraged. — The Atlantic";
pressQuotes[2]="NAPS has changed the way people think about sleep, on a grand scale. — Washington Post";
pressQuotes[3]="Happiness increased 200% since NAPS began promoting siestas. — National Science Review";
pressQuotes[4]="NAPS has ushered in a new era of sleep. — USA Today";
pressQuotes[5]="Not surprisingly, more siestas means more productivity. — Wall Street Journal";
pressQuotes[6]="NAPS is doing the hard work of helping people get the rest they need. — U.S. News";

var rando = Math.floor(Math.random()*pressQuotes.length);

$("#press-quote").html(pressQuotes[rando]);
});


which changed the text everytime the page was reloaded. Knowing how to troubleshoot code is useful to a web designer when debugging and fixing their websites.

Link: http://techteach.us/Web2020/ZWeiJian/WCP/Labs/Lab_08/



No comments:

Post a Comment