Back to Freecodecamp

Step 5

curriculum/challenges/english/blocks/workshop-loan-qualification-checker/66c8ba975ee7230e29f6c4b0.md

latest1.3 KB
Original Source

--description--

Now, you should check if the applicant is qualified for a car loan only. If they are, return the string "You qualify for a car loan.".

--hints--

Your getLoanMessage function should return a string if the applicant qualifies for a car loan.

js
assert.isString(getLoanMessage(30000, 650));

Your getLoanMessage function should return the string "You qualify for a car loan.".

js
assert.strictEqual(getLoanMessage(30000, 650), "You qualify for a car loan.");

Your getLoanMessage function should return undefined if the applicant's annual income and credit score do not meet the requirements for a car loan.

js
assert.strictEqual(getLoanMessage(30000, 600), undefined);

--seed--

--seed-contents--

js
const minIncomeForDuplex = 60000;
const minCreditScoreForDuplex = 700;

const minIncomeForCondo = 45000;
const minCreditScoreForCondo = 680;

const minIncomeForCar = 30000;
const minCreditScoreForCar = 650;

function getLoanMessage(annualIncome, creditScore) {
  if(creditScore >= minCreditScoreForDuplex && annualIncome >= minIncomeForDuplex) {
    return "You qualify for a duplex, condo, and car loan."
  } else if (annualIncome >= minIncomeForCondo && creditScore >= minCreditScoreForCondo) {
    return "You qualify for a condo and car loan."
--fcc-editable-region--
  } 
  
--fcc-editable-region--
}