From 13e4c9280034c29974adeaf2746db8c66e6aaf09 Mon Sep 17 00:00:00 2001 From: atomiks Date: Sun, 31 Dec 2017 17:19:55 +1100 Subject: [PATCH] Avoid repeating function call --- snippets/elo.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snippets/elo.md b/snippets/elo.md index 991b74019..1fbbe1986 100644 --- a/snippets/elo.md +++ b/snippets/elo.md @@ -11,8 +11,7 @@ and compute the new rating for each. Omit the second argument to use the default ```js const elo = ([a, b], kFactor = 32) => { const expectedScore = (self, opponent) => 1 / (1 + Math.pow(10, (opponent - self) / 400)); - const newRating = (rating, i) => - rating + kFactor * (i - (i ? expectedScore(a, b) : expectedScore(b, a))); + const newRating = (rating, i) => rating + kFactor * (i - expectedScore(i ? a : b, i ? b : a)); return [newRating(a, 1), newRating(b, 0)]; }; ```