diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/core/group3.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/group3.js')
-rw-r--r-- | jstests/core/group3.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/jstests/core/group3.js b/jstests/core/group3.js index d113b9d570f..134953b6649 100644 --- a/jstests/core/group3.js +++ b/jstests/core/group3.js @@ -6,20 +6,20 @@ t.save({a: 2}); t.save({a: 3}); t.save({a: 4}); - -cmd = { initial: {count: 0, sum: 0}, - reduce: function(obj, prev) { - prev.count++; - prev.sum += obj.a; - }, - finalize: function(obj) { - if (obj.count){ - obj.avg = obj.sum / obj.count; - }else{ - obj.avg = 0; - } - }, - }; +cmd = { + initial: {count: 0, sum: 0}, + reduce: function(obj, prev) { + prev.count++; + prev.sum += obj.a; + }, + finalize: function(obj) { + if (obj.count) { + obj.avg = obj.sum / obj.count; + } else { + obj.avg = 0; + } + }, +}; result1 = t.group(cmd); @@ -28,11 +28,10 @@ assert.eq(10, result1[0].sum, "test1"); assert.eq(4, result1[0].count, "test1"); assert.eq(2.5, result1[0].avg, "test1"); - cmd['finalize'] = function(obj) { - if (obj.count){ + if (obj.count) { return obj.sum / obj.count; - }else{ + } else { return 0; } }; |