-2

我不断收到此错误:-看起来您的函数没有返回“唉,您没有资格获得信用卡。资本主义就是那样残酷。当收入参数为 75 时。

有人可以告诉我我做错了什么吗?干杯:)

var creditCheck = function(income)
if(income >= 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.";
}


creditCheck(75);
creditCheck(125);
creditCheck(100);
4

2 回答 2

2
var creditCheck = function(income) {
    if(income >= 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.";
    }
};

此外,您正在返回一个字符串,您尚未将其打印到屏幕或控制台,否则您将什么也看不到。

于 2013-08-04T17:26:17.613 回答
1

如何打开和关闭该功能:

var creditCheck = function (income) {
    if (income >= 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.";
    }
}

小提琴

于 2013-08-04T17:25:42.170 回答