I think we can just write <code>var newRating = (userRating === dbRating) ? userRating - 1 : userRating</code> because we don't really need a function for this, also the checkRatings() only used once.