Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

java script function syntax?

An especially useful application of reusable code is if/else statements. These can be very wordy, and a pain to type repeatedly.

We are going to write a function that takes a person's income as the parameter. Inside the function will be an if / else statement. We want the function to be available to check whether many different people's income qualifies for them for a credit card.

Write a function called creditCheck that takes the parameter income.

Inside the function, write an if statement where if the income is greater than or equal to 100, the computer will return "You earn a lot of money! You qualify for a credit card."

If the income is less than 100, have the computer return "Alas you do not qualify for a credit card. Capitalism is cruel like that."

Call the function passing in an income of 75

AFTER you call it with 75, call it with 125

AFTER you call it with 125, call it with 100. Have to be sure!

my code {var creditCheck = function (income)

if (income > or === 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))

console.log(creditCheck(125))

console.log(creditCheck(100))

}

The error says missing operand; found if

Update:

As much as I hate to have to say it saman it didn't work. Got the same error??

1 Answer

Relevance
  • 8 years ago
    Favorite Answer

    {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.")

    }

    console.log(creditCheck(75));

    console.log(creditCheck(125));

    console.log(creditCheck(100));

    }

    This will work.

Still have questions? Get your answers by asking now.