Skip to content

Commit

Permalink
Fix math error in ratings snippet (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed Jan 8, 2018
1 parent d614297 commit 14d21e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion firestore/test.firestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ describe("firestore", () => {

// Compute new average rating
var oldRatingTotal = res.data().avgRating * res.data().numRatings;
var newAvgRating = (oldRatingTotal * rating) / newNumRatings;
var newAvgRating = (oldRatingTotal + rating) / newNumRatings;

// Commit to Firestore
transaction.update(restaurantRef, {
Expand Down

0 comments on commit 14d21e9

Please sign in to comment.