$('button').click(function () {
[1, 2, 3, 4, 5].forEach(function (n) {
if (n == 3) {
// it should break out here and doesn't alert anything after
return false
}
alert(n)
})
})Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>Click me</button>Run Code Online (Sandbox Code Playgroud)
我的问题:虽然我打电话,为什么它仍会提醒下一个号码return?就像:忽略下面的代码并继续下一个元素
我正在尝试编写代码,返回给定的整数是否可以被1到20均分,
但我一直收到以下错误:
错误CS0161:'ProblemFive.isTwenty(int)':并非所有代码路径都返回一个值
这是我的代码:
public static bool isTwenty(int num)
{
for(int j = 1; j <= 20; j++)
{
if(num % j != 0)
{
return false;
}
else if(num % j == 0 && num == 20)
{
return true;
}
}
}
Run Code Online (Sandbox Code Playgroud)