Question: Currently working on a CSS/HTML question and having some trouble with the JS portion. Any help will be appreciated. Here is what I'm trying to
Currently working on a CSS/HTML question and having some trouble with the JS portion. Any help will be appreciated. Here is what I'm trying to do:
Declare a variable named ratingsSumsetting its initial value to 0.
Declare a variable named ratingsCount equal to the length of the ratings array.
Create a for loop to loop through the contents of the ratings array. Each time through the loop, add the value of current ratings value to the value of the ratingsSum variable.
After the for loop, declare the ratingsAvgvariable, setting its value equal to the value of the ratingsSumvariable divided by the value of ratingsCount.
Declare a variable named ratingReport. Set its initial value to the text string
Customer Reviews
average out of 5 stars ( count reviews)
where average is the value of the ratingsAvg variable and count is the value of ratingsCount..
Here's what I have:
var gameReport = "
title
By: manufacturer
document.getElementsByTagName("article.+=.+gameReport")[0].innerHTML;
var ratingsSum = 0; var ratingsCount = ratings.length; for (var i = 0; i Customer Reviews
average out of 5 stars ( count reviews)
";document.getElementByTagName("aside.+=.+ratingReport")[0].innerHTML;
I also have to do this:
.Create a for loop in which the counter goes from 0 to 2 in steps of 1. Within the for loop, insert the commands described in the following steps:
Add the following HTML code to the value of the ratingReport variable
Customer Reviews
average out of 5 stars ( count reviews)
| where title is the value of the ratingTitles array item for current review, author is the value of the current ratingAuthors array item, and date is the value of the current ratingDates item. Each customer rates the game on a scale of 1 to 5 stars. Sean would like to have the stars displayed graphically. Add a nested for loop where the counter goes from 1 up to the value of the current customer rating of the game in increments of one. Each time through the nested for loop, add the following HTML code to the value of the ratingReport variable:
Directly after the nested for loop, but still within the outer for loop, insert commands to add the following HTML code to the value of the ratingReport variable |
summary
where summary is the value from the ratingSummaries array for the current customer review. info>
Write the value of the ratingReport variable to the inner HTML of the first and only aside element in the document.
(Hint : As you did with the article element, use the getElementsByTagName()method and reference the first item from the array of aside elements.)
I think that once I get over the first hump, I'll be fine. Edit: Don't worry about the last part, I've already figured that out. I'm still stumped on the first for loop though and the first few variables declared.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
