Created
June 12, 2017 07:41
-
-
Save musale/d37e1aeed3c6f7eeffc5709494a0ea79 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kobitaz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var desks = [{ type: 'sitting' }, { type: 'standing' }, { type: 'sitting' }, { type: 'sitting' }, { type: 'standing' }]; | |
desks.reduce(function (desksCount, desk) { | |
desksCount[desk.type] = (desksCount[desk.type] || 0) + 1; | |
console.log(desksCount); | |
return desksCount; | |
}, {}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const desks = [ | |
{ type: 'sitting' }, | |
{ type: 'standing' }, | |
{ type: 'sitting' }, | |
{ type: 'sitting' }, | |
{ type: 'standing' } | |
]; | |
desks.reduce((desksCount, desk) => { | |
desksCount[desk.type] = (desksCount[desk.type] || 0) + 1; | |
console.log(desksCount) | |
return desksCount | |
}, {}); | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var desks = [{ type: 'sitting' }, { type: 'standing' }, { type: 'sitting' }, { type: 'sitting' }, { type: 'standing' }]; | |
desks.reduce(function (desksCount, desk) { | |
desksCount[desk.type] = (desksCount[desk.type] || 0) + 1; | |
console.log(desksCount); | |
return desksCount; | |
}, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment