从arguments对象中获取数组中的值,然后使用for循环返回答案

时间:2017-01-11 04:32:34

标签: function loops printing

感谢您抽出宝贵时间阅读本文! 我的目标是学习如何通过获取函数参数对象中的值来打印所有结果。

enter code here

function solve(args) {
    var numb = +args.length,
        numbBySeven = numb % 7 === 0,
        numbByFive = numb % 5 === 0,
        i;
    for (i = 0; i < numb; index++) {
        if (numbBySeven && numbByFive) {
            return 'true ' + numb;  //print this 
        } else {
            return 'false ' + numb; // print this 
        }
    }
}
console.log("solve ", solve(['35', '35', '35', '35', '35', '35'])); // from this 

1 个答案:

答案 0 :(得分:0)

您想要与此相似吗?

function solve(args) {
    var numb = args.length;
for(var j = 0; j<numb;j++){
        var numbBySeven = numb[j] % 7 === 0
        var numbByFive = numb[j] % 5 === 0

        if (numbBySeven && numbByFive) {
            console.log( 'true ' + numb[j])  //print this
        } else {
            console.log( 'flase ' + numb[j]) // print this
        }

}
}

console.log(solve(['35', '35', '35', '35', '35', '35']))