📌  相关文章
📜  javascript代码示例中的加减hackerrank解决方案

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

代码示例1
function plusMinus(arr) {
    let positive = arr.filter(number => number > 0).length / arr.length;
    let negative = arr.filter(number => number < 0).length / arr.length;;
    let zeronums = arr.filter(number => number == 0).length / arr.length;;
    return console.log(positive.toFixed(6) + '\n' + negative.toFixed(6) + '\n' + zeronums.toFixed(6))
}