js 中if else if
这个是不是可以包夹很多个的???问题:Addanelseifbranchtoyourexistingif/elsestatement.Ifthenumberputinto...
这个是不是可以包夹很多个的???
问题:Add an else if branch to your existing if/else statement. If thenumber put into the function is not a number at all, instead of returntrue; or return false;, the function should return a string that tells the user that their input isn't a number. (This string can say whatever you like.)
------------------------------------------代码-----------------------
var isEven = function(number) {
if(number % 2 ==0){
return true ;}
else{
return false;}
}
else if(isNaN(isEven)){
return "ok,go on"}
else{
return "please input a number"}
-------------------------------问题-------------------------------
靠,这个,妈蛋的我知道知道这个是错的肯定是错的,系统叫我弄额ELSE IF的结构,神经,我就是不会弄,我就掉在这个坑了,其他的估计没有错。!! 展开
问题:Add an else if branch to your existing if/else statement. If thenumber put into the function is not a number at all, instead of returntrue; or return false;, the function should return a string that tells the user that their input isn't a number. (This string can say whatever you like.)
------------------------------------------代码-----------------------
var isEven = function(number) {
if(number % 2 ==0){
return true ;}
else{
return false;}
}
else if(isNaN(isEven)){
return "ok,go on"}
else{
return "please input a number"}
-------------------------------问题-------------------------------
靠,这个,妈蛋的我知道知道这个是错的肯定是错的,系统叫我弄额ELSE IF的结构,神经,我就是不会弄,我就掉在这个坑了,其他的估计没有错。!! 展开
2个回答
展开全部
var isEven = function(number) {
if(!isNaN(parseFloat(number)) && isFinite(number)){
return "ok, go on !";
} else {
return "please input a number";
}
}
or
var isEven = function(number) {
if(number - parseFloat(number) >= 0){
return "ok, go on !";
} else {
return "please input a number";
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询