diff --git a/app.js b/app.js index 7488b5d2..69a58732 100644 --- a/app.js +++ b/app.js @@ -29,14 +29,15 @@ rl.on('line', (line) => { } }); rl.on('close', () => { - for (let [key, value] of prefectureDataMap) { + for (let pair of prefectureDataMap) { + const value = pair[1]; value.change = value.popu15 / value.popu10; } const rankingArray = Array.from(prefectureDataMap).sort((pair1, pair2) => { - return pair2[1].change - pair1[1].change; + return pair1[1].change - pair2[1].change; }); - const rankingStrings = rankingArray.map(([key, value]) => { - return key + ': ' + value.popu10 + '=>' + value.popu15 + ' 変化率:' + value.change; + const rankingStrings = rankingArray.map((pair,i) => { + return 'RANK' + (i + 1) +': ' + pair[0] + ': ' + pair[1].popu10 + '=>' + pair[1].popu15 + ' 変化率:' + pair[1].change; }); console.log(rankingStrings); });