File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,13 @@ let selectedRating = 0; //selected rating
55let totalRating = 0 ; //total rating
66let 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+ }
812submitButton . 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- }
You can’t perform that action at this time.
0 commit comments