Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
result5 の作成にreduceとfilterを使用
  • Loading branch information
jun68ykt committed Aug 9, 2019
1 parent dd8fe1c commit c6ffc00
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions main.js
Expand Up @@ -25,16 +25,14 @@ document.addEventListener('DOMContentLoaded', function() {

console.log(result4);

var result5 = [];
for (var i = 0; i < result4.length; i++) {
for (var j = 0; j < result4[i].length; j++) {
k = result4[i][j][2];
if (!result5[k]) {
result5[k] = [];
}
result5[k].push(result4[i][j]);
}
}
var result5 = result4.reduce((a, e) => ([...a, ...e]), [])
.filter(a => a.length > 1)
.reduce(
(obj, e) => ({
...obj,
[e[2]]: obj[e[2]] ? [...obj[e[2]], e] : [e]
})
,{});
console.log(result5);
}
},false);
Expand Down

0 comments on commit c6ffc00

Please sign in to comment.