feat: adding loan qualification checker (#55955)

Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com>
Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
This commit is contained in:
Kolade Chris
2024-09-11 13:00:30 +01:00
committed by GitHub
parent 0257cbdb60
commit 415116b69e
10 changed files with 567 additions and 0 deletions
+7
View File
@@ -1955,6 +1955,13 @@
"In this lab, you will create different stories by assigning different words to different variables."
]
},
"workshop-loan-qualification-checker": {
"title": "Build a Loan Qualification Checker",
"intro": [
"In this workshop, you will continue to learn how to work with conditionals by building a loan qualification checker app.",
"You will learn more about <code>if</code> statements, and how to use comparison operators and multiple conditions in an <code>if</code> statement."
]
},
"lab-leap-year-calculator": {
"title": "Build a Leap Year Calculator ",
"intro": [
@@ -0,0 +1,9 @@
---
title: Introduction to the Build a Loan Qualification Checker
block: workshop-loan-qualification-checker
superBlock: front-end-development
---
## Introduction to the Build a Loan Qualification Checker
This is a test for the new project-based curriculum.
@@ -0,0 +1,41 @@
{
"name": "Build a Loan Qualification Checker",
"isUpcomingChange": true,
"usesMultifileEditor": true,
"hasEditableBoundaries": true,
"blockType": "workshop",
"dashedName": "workshop-loan-qualification-checker",
"order": 154,
"superBlock": "front-end-development",
"challengeOrder": [
{
"id": "66c8ba41a77db20a93f9d7a1",
"title": "Step 1"
},
{
"id": "66c8ba975ee7230e29f6c4ac",
"title": "Step 2"
},
{
"id": "66c8ba975ee7230e29f6c4ad",
"title": "Step 3"
},
{
"id": "66c8ba975ee7230e29f6c4af",
"title": "Step 4"
},
{
"id": "66c8ba975ee7230e29f6c4b0",
"title": "Step 5"
},
{
"id": "66c8ba975ee7230e29f6c4b1",
"title": "Step 6"
},
{
"id": "66c8ba975ee7230e29f6c4b2",
"title": "Step 7"
}
],
"helpCategory": "JavaScript"
}
@@ -0,0 +1,71 @@
---
id: 66c8ba41a77db20a93f9d7a1
title: Step 1
challengeType: 1
dashedName: step-1
---
# --description--
In this workshop, you'll review JavaScript conditionals by building a loan qualification checker app.
The app will check whether the user is eligible for a duplex, car, and condo loan based on their annual income and credit score. A credit score is a number that represents how good you are at managing borrowed money.
To get started, create the following variables and values.
| Variable Name | Value |
| ----------- | ------- |
| `minIncomeForDuplex` | `60000` |
| `minCreditScoreForDuplex` | `700` |
| `minIncomeForCondo` | `45000` |
| `minCreditScoreForCondo` | `680` |
| `minIncomeForCar` | `30000` |
| `minCreditScoreForCar` | `650` |
# --hints--
You should create a `minIncomeForDuplex` variable set to `60000`.
```js
assert.equal(minIncomeForDuplex, 60000);
```
You should create a `minCreditScoreForDuplex` set to `700`.
```js
assert.equal(minCreditScoreForDuplex, 700);
```
You should create a `minIncomeForCar` variable set to `30000`.
```js
assert.equal(minIncomeForCar, 30000);
```
You should create a `minCreditScoreForCar` variable set to `650`.
```js
assert.equal(minCreditScoreForCar, 650);
```
You should create a `minIncomeForCondo` variable set to `45000`.
```js
assert.equal(minIncomeForCondo, 45000);
```
You should create a `minCreditScoreForCondo` variable set to `680`.
```js
assert.equal(minCreditScoreForCondo, 680);
```
# --seed--
## --seed-contents--
```js
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,53 @@
---
id: 66c8ba975ee7230e29f6c4ac
title: Step 2
challengeType: 1
dashedName: step-2
---
# --description--
When the user is eligible for a loan, you'll want to display a message to them in the console.
For that, you'll build out a function inside which you'll have some checks that'll return what loan the applicant is eligible for.
Create an empty `getLoanMessage` function with an `annualIncome` and `creditScore` parameters.
# --hints--
You should create a `getLoanMessage` function
```js
assert.isFunction(getLoanMessage)
```
Your `getLoanMessage` function should have an `annualIncome` and `creditScore` as parameters.
```js
assert.match(getLoanMessage?.toString(), /\(\s*annualIncome,\s*creditScore\s*\)|\(\s*creditScore,\s*annualIncome\s*\)/);
```
`getLoanMessage` should be an empty function.
```js
assert.match(getLoanMessage?.toString(), /\{\s*\}/);
```
# --seed--
## --seed-contents--
```js
const minIncomeForDuplex = 60000;
const minCreditScoreForDuplex = 700;
const minIncomeForCondo = 45000;
const minCreditScoreForCondo = 680;
const minIncomeForCar = 30000;
const minCreditScoreForCar = 650;
--fcc-editable-region--
--fcc-editable-region--
```
@@ -0,0 +1,55 @@
---
id: 66c8ba975ee7230e29f6c4ad
title: Step 3
challengeType: 1
dashedName: step-3
---
# --description--
To check which loan a user is qualified for based on the `annualIncome` and `creditScore`, you have to use `if/else if` statement or a ternary right inside the `getLoanMessage` function. You'll then return the appropraite message in the block of each condition.
Starting with the duplex loan, check if `annualIncome` is greater than or equal to `minIncomeForDuplex` AND if `creditScore` is greater than `minCreditScoreForDuplex`.
If that condition is true, then the applicant is eligible for a duplex loan and the other loans. So, inside the check, return the string `"You qualify for a car, duplex and Condo loan."`
# --hints--
Your `getLoanMessage` function should return a string.
```js
assert.isString(getLoanMessage(65000, 750));
```
Your `getLoanMessage` function should return the string `"You qualify for a duplex, condo, and car loan."`.
```js
assert.strictEqual(getLoanMessage(65000, 750), "You qualify for a duplex, condo, and car loan.");
```
Your `getLoanMessage` function should return `undefined` if the applicant's annual income and credit score do not meet the requirements for a duplex loan.
```js
assert.strictEqual(getLoanMessage(59000, 700), undefined);
```
# --seed--
## --seed-contents--
```js
const minIncomeForDuplex = 60000;
const minCreditScoreForDuplex = 700;
const minIncomeForCondo = 45000;
const minCreditScoreForCondo = 680;
const minIncomeForCar = 30000;
const minCreditScoreForCar = 650;
--fcc-editable-region--
function getLoanMessage(annualIncome, creditScore) {
}
--fcc-editable-region--
```
@@ -0,0 +1,56 @@
---
id: 66c8ba975ee7230e29f6c4af
title: Step 4
challengeType: 1
dashedName: step-4
---
# --description--
If the applicant's annual income is greater than or equal to `minIncomeForCondo`, AND if their credit score is greater than or equal to `minCreditScoreForCondo`, then they qualify for a condo and car loan.
Check if that's true in the `getLoanMessage` function. If it is, return the string `"You qualify for a condo and car loan."`
# --hints--
Your `getLoanMessage` function should return a string if the applicant qualifies for a condo and car loan.
```js
assert.isString(getLoanMessage(45000, 680));
```
Your `getLoanMessage` function should return the string `"You qualify for a condo and car loan."`.
```js
assert.strictEqual(getLoanMessage(45000, 680), "You qualify for a condo and car loan.");
```
Your `getLoanMessage` function should return `undefined` if the applicant's annual income and credit score do not meet the requirements for a condo loan.
```js
assert.strictEqual(getLoanMessage(45000, 650), 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."
--fcc-editable-region--
}
--fcc-editable-region--
}
```
@@ -0,0 +1,56 @@
---
id: 66c8ba975ee7230e29f6c4b0
title: Step 5
challengeType: 1
dashedName: step-5
---
# --description--
Now, you should check if the applicant is qualified for a car loan only. If they're, 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--
}
```
@@ -0,0 +1,54 @@
---
id: 66c8ba975ee7230e29f6c4b1
title: Step 6
challengeType: 1
dashedName: step-6
---
# --description--
If the applicant's annual income and credit score fall below `minIncomeForCar` and `minCreditScoreForCar`, then they don't qualify for any loan. So, return the string `"You don't qualify for any loans."`
# --hints--
Your `getLoanMessage` function should return a string if the applicant doesn't qualify for any loan.
```js
assert.isString(getLoanMessage(25000, 550));
```
Your `getLoanMessage` function should return the string `"You don't qualify for any loans."` if the applicant does not meet the requirements for any loan.
```js
assert.strictEqual(getLoanMessage(15000, 600), "You don't qualify for any loans.");
assert.strictEqual(getLoanMessage(25000, 550), "You don't qualify for any loans.");
assert.strictEqual(getLoanMessage(20000, 500), "You don't qualify for any loans.");
```
# --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."
} else if (annualIncome >= minIncomeForCar && creditScore >= minCreditScoreForCar) {
return "You qualify for a car loan."
--fcc-editable-region--
}
--fcc-editable-region--
}
```
@@ -0,0 +1,165 @@
---
id: 66c8ba975ee7230e29f6c4b2
title: Step 7
challengeType: 1
dashedName: step-7
---
# --description--
Now, it is time to test out your `getLoanMessage` function.
Use the table below to create `4` variables and their values:
| Variable Name | Value |
| ----------- | ------- |
| `duplexLoanMsg` | `getLoanMessage(85000, 850)` |
| `condoLoanMsg` | `getLoanMessage(65000, 690)` |
| `carLoanMsg` | `getLoanMessage(45000, 660)` |
| `noLoanMsg` | `getLoanMessage(25000, 550)` |
After that, log each variable to the console to see the messages.
With that, your loan qualification checker project is complete!
# --hints--
You should have a variable called `duplexLoanMsg`.
```js
assert.isNotNull(duplexLoanMsg);
```
Your `duplexLoanMsg` variable should be set to the result of `getLoanMessage(85000, 850)`.
```js
assert.equal(duplexLoanMsg, getLoanMessage(85000, 850));
```
You should log the `duplexLoanMsg` variable to the console.
```js
assert.match(code, /console\.log\(duplexLoanMsg\)/)
```
You should have a variable called `condoLoanMsg`.
```js
assert.isNotNull(condoLoanMsg);
```
Your `condoLoanMsg` variable should be set to the result of `getLoanMessage(65000, 690)`.
```js
assert.equal(condoLoanMsg, getLoanMessage(65000, 690));
```
You should log the `condoLoanMsg` variable to the console.
```js
assert.match(code, /console\.log\(condoLoanMsg\)/)
```
You should have a variable called `carLoanMsg`.
```js
assert.isNotNull(carLoanMsg);
```
Your `carLoanMsg` variable should be set to the result of `getLoanMessage(45000, 660)`.
```js
assert.equal(carLoanMsg, getLoanMessage(45000, 660));
```
You should log the `carLoanMsg` variable to the console.
```js
assert.match(code, /console\.log\(carLoanMsg\)/)
```
You should have a variable called `noLoanMsg`.
```js
assert.isNotNull(noLoanMsg);
```
Your `noLoanMsg` variable should be set to the result of `getLoanMessage(25000, 550)`.
```js
assert.equal(noLoanMsg, getLoanMessage(25000, 550));
```
You should log the `noLoanMsg` variable to the console.
```js
assert.match(code, /console\.log\(noLoanMsg\)/)
```
# --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."
} else if (annualIncome >= minIncomeForCar && creditScore >= minCreditScoreForCar) {
return "You qualify for a car loan."
} else {
return "You don't qualify for any loans."
}
}
--fcc-editable-region--
--fcc-editable-region--
```
# --solutions--
```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."
} else if (annualIncome >= minIncomeForCar && creditScore >= minCreditScoreForCar) {
return "You qualify for a car loan."
} else {
return "You don't qualify for any loans."
}
}
const duplexLoanMsg = getLoanMessage(85000, 850)
console.log(duplexLoanMsg)
const condoLoanMsg = getLoanMessage(65000, 690)
console.log(condoLoanMsg)
const carLoanMsg = getLoanMessage(45000, 660)
console.log(carLoanMsg)
const noLoanMsg = getLoanMessage(25000, 550)
console.log(noLoanMsg)
```