📜  将整数月份转换为字符串月份反应本机 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:54.055000             🧑  作者: Mango

代码示例1
var label = [{month: 9, revenue: 400}, 
            {month: 11, revenue: 500},
            {month: 12, revenue: 600}]

var months = [];
var revenue = [];
var m = [ "January", "February", "March", "April", "May", "June", 
           "July", "August", "September", "October", "November", "December" ];

label.forEach(function(value){
    var monthName = m[value.month - 1];
    months.push(monthName);
    revenue.push(value.revenue);
});

console.log('Months Array: ', months);
console.log('Revenue Array:', revenue);