本文介绍了非法返回语句错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的退货声明有什么问题?
What is wrong with my return statement?
var creditCheck = function (income) {
var val = income;
return val;
};
if (creditCheck > 100) {
return "You earn a lot of money! You qualify for a credit card.";
} else {
return "Alas, you do not qualify for a credit card. Capitalism is cruel like that.";
}
console.log(creditCheck(75));
推荐答案
您的返回
语句不在任何函数之内。您只能在函数中使用 return
。
Your return
statements are outside of any function. You can only use return
within a function.
(您还要将函数与整数进行比较,in if(creditCheck> 100)
- 你的意思是在那里调用函数吗?)
(You're also comparing a function with an integer, in if (creditCheck > 100)
- did you mean to call the function there?)
这篇关于非法返回语句错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!