process.stdin.resume();
process.stdin.setEncoding('utf8');
const Equipment = [
{name: "剣", value: "どうのつるぎ"},
{name: "防具", value: "かわのたて"},
{name: "防止", value: "かわのぼうし"},
{name: "ナイフ", value: "ブロンズナイフ"}
];
data = Equipment.reduce(function(p,c){
if(p[c['name']] === undefined){
p[c['name']] = [];
}
p[c['name']].push(c['value']|0);
return p;
}, {});
console.log(data);
#結果 ⇛ 連想配列になる
{
'剣': [ 'どうのつるぎ' ],
'防具': [ 'かわのたて' ],
'防止': [ 'かわのぼうし' ],
'ナイフ': [ 'ブロンズナイフ' ]
}
var player ={name: "Ronaldo", team: "Juventus"};
player.uniNumber = 7;
console.log(player);