Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 从arguments对象的数组中获取值,然后使用for循环返回答案_Function_Loops_Printing - Fatal编程技术网

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

Function 从arguments对象的数组中获取值,然后使用for循环返回答案,function,loops,printing,Function,Loops,Printing,感谢您抽出时间阅读此文章! 我的最终目标是学习如何通过获取放在functions arguments对象中的值来打印所有结果 enter code here function solve(args) { var numb = +args.length, numbBySeven = numb % 7 === 0, numbByFive = numb % 5 === 0, i; for (i = 0; i < numb; ind

感谢您抽出时间阅读此文章! 我的最终目标是学习如何通过获取放在functions arguments对象中的值来打印所有结果

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 
在此处输入代码
函数求解(args){
变量numb=+args.length,
numbBySeven=numb%7==0,
numbByFive=numb%5==0,
我
对于(i=0;i
您希望类似于此吗?

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']))
函数求解(args){
var numb=args.length;

对于(var j=0;jj你用什么语言来做这件事?不同的语言有不同的方法。这似乎是javascript?所以你做了一个从j到args的循环。然后,你检查每个索引j,如果它可以被5和7整除,然后检查条件语句,验证真或假,然后用每个索引打印它。是的谢谢你的快速回答。