📜  js 数组分类新成员 - Javascript 代码示例

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

代码示例1
function openOrSenior(data){
      // using map and ternary operator.
    return data.map( x => x[0] >= 55 && x[1] > 7 ? "Senior" : "Open");
}

console.log(openOrSenior([[45, 12],[55,21],[19, -2],[104, 20]])); //,['Open', 'Senior', 'Open', 'Senior'])
console.log(openOrSenior([[3, 12],[55,1],[91, -2],[54, 23]])); //,['Open', 'Open', 'Open', 'Open'])
console.log(openOrSenior([[59, 12],[55,-1],[12, -2],[12, 12]])); //,['Senior', 'Open', 'Open', 'Open'])