Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,26 @@ As you work on your code you should make use of `console.log` to check your prog

### Task 2b: Exit Ticket

Once you begin, you will have 15 minutes to answer the questions [here](https://app.codesignal.com/public-test/pi7Q49mgrZbodiRzM/aXzit9h4ZRp3Si)
- [x] Once you begin, you will have 15 minutes to answer the questions [here](https://app.codesignal.com/public-test/pi7Q49mgrZbodiRzM/aXzit9h4ZRp3Si)

The completion of these questions is mandatory for MVP. However, passing the quiz doesn't affect your standing as a Lambda School student whatsoever. This is Lambda School testing itself! Please answer honestly and to the best of your ability without using external references.

### Task 3: Stretch Goals

After you have completed the requirements, try any of the following challenges. As always, note that these may require additional research beyond what you learned in this module.

- [ ] Add `Property Tax`, `Homeowner's insurance` and `HOA fees` as parameters in your function to calculate total monthly spending on housing
- [ ] Build a calculator function that accepts `monthly payment` and `interest rate` and returns the maximum loan that a person could afford
- [ ] Explore using `window.prompt()` to allow a user to input parameters in the browser
- [ ] Refactor your `variableInterestRate()` function to accept an array of interest rates (make sure to copy and paste as to not lose your work!)
- [x] Add `Property Tax`, `Homeowner's insurance` and `HOA fees` as parameters in your function to calculate total monthly spending on housing
- [x] Build a calculator function that accepts `monthly payment` and `interest rate` and returns the maximum loan that a person could afford
- [x] Explore using `window.prompt()` to allow a user to input parameters in the browser
- [x] Refactor your `variableInterestRate()` function to accept an array of interest rates (make sure to copy and paste as to not lose your work!)

## Submission format

Follow these steps for completing your project.

1. [ ] Submit a pull request to merge `<firstName-lastName>` branch into master. **Please don't merge your own pull request**
2. [ ] Add your TL as a reviewer on the pull-request
3. [ ] Your TL will count the project as complete by merging the branch back into master
1. [x] Submit a pull request to merge `<firstName-lastName>` branch into master. **Please don't merge your own pull request**
2. [x] Add your TL as a reviewer on the pull-request
3. [x] Your TL will count the project as complete by merging the branch back into master

## Resources

Expand Down
51 changes: 49 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,57 @@
<title>JavaScript Foundations</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Creepster&display=swap" rel="stylesheet">
</head>
<body>
<p>Open up the console to check your work!</p>


<p class="introText">Want to know your mortgage?</p>

<script src="index.js"></script>
<div class="container2">
<button class="mortgageButton" onclick="mortgageCalculator()">Mortgage Calculator</button>
</div>


<p id="result"></p>



<script>
// function myFunction() {
// var person = prompt("Please enter your name", "Harry Potter");
// if (person != null) {
// document.getElementById("demo").innerHTML =
// "Hello " + person + "! How are you today?";
// }
// }

function mortgageCalculator() {
// var name = prompt("Please enter your name.");

var principal = prompt("Please enter your principal.");

let interestRate = 0.05;
let years = 30;

let monthlyInterestRate = interestRate / 12;
let periods = years * 12;

let n1 = Math.pow((1 + monthlyInterestRate),periods);
let numerator = principal * n1 * monthlyInterestRate;
let denominator = n1 - 1;
let monthlyRate = numerator / denominator;
monthlyRate = monthlyRate.toFixed(2);

// return `${name}, your monthly rate is ${monthlyRate}.`
document.getElementById("result").innerHTML =
"Your monthly rate is $" + monthlyRate + ".";

}

</script>

<!-- <script src="index.js"></script> -->
</body>
</html>
Loading