Skip to content

Commit 38c30f0

Browse files
committed
Change function position
1 parent ec65c54 commit 38c30f0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

main.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ let selectedRating = 0; //selected rating
55
let totalRating = 0; //total rating
66
let numberOfRatings = 0; //number of ratings
77

8+
function changeRating(rating) {
9+
//function to change selected rating
10+
selectedRating = rating; //set selected rating to the given rating
11+
}
812
submitButton.addEventListener("click", () => {
913
//when submit button is clicked
1014
totalRating += selectedRating; //add selected rating to total rating
1115
numberOfRatings++; //increase number of ratings by 1
1216
ratingOutputText.textContent = `Selected rating: ${selectedRating}/5\nAverage rating: ${(totalRating / numberOfRatings).toFixed(2)}\nTotal ratings: ${numberOfRatings}`; //update rating output text
1317
});
14-
15-
function changeRating(rating) {
16-
//function to change selected rating
17-
selectedRating = rating; //set selected rating to the given rating
18-
}

0 commit comments

Comments
 (0)