Skip to content

Kd practice #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ Follow these steps for completing your project.
👀 [Mortgage Calculator Web App for Inspiration](https://www.bankrate.com/calculators/mortgages/mortgage-calculator.aspx)

🤟 [window.prompt for Stretch Goals](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt)


//
66 changes: 66 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
/* Create variables for principal, interest rate, and years. Assign them the values 200000, 0.05, and 30 respectively. Create another value called name and give it the value of your own name.
*/

// let principal= 200000;
// let interestRate=0.05;
// let years = 30;

// const name ="katrina"

// console.log(principal)
// console.log(interestRate)
// console.log(years)



Expand All @@ -15,7 +23,19 @@
(2) Create another variable called `periods` and give it the value of years*12.
*/

// const monthlyInterestRate = (interestRate / 12)
// const periods = (years * 12)

// console.log(monthlyInterestRate)
// console.log(periods)


// let principal= 200000;
// let interestRate=0.05;
// let years = 30;

// let monthlyInterestRate = (interestRate / 12)
// let periods = (years * 12)


// 🏡 Task 2: Harder Math
Expand All @@ -35,6 +55,17 @@ Hint #2: you'll need to use the `math` object for parts of this calculation!
When your math is correct, monthlyRate will equal 1073.64
*/

let principal= 200000;
let interestRate=0.05;
let years = 30;

let monthlyInterestRate = (interestRate / 12)
let periods = (years * 12)

const monthlyRate = function(){
return principal * (Math.pow( 1+ monthlyInterestRate, periods)*(monthlyInterestRate) / ((Math.pow(1 + monthlyInterestRate, periods)-1)));
}
console.log(monthlyRate().toFixed(2))



Expand All @@ -45,6 +76,16 @@ If your name is `Oscar` mortgageCalculator() should return "Oscar, your monthly
*/


P = principal
I = monthlyInterestRate
N = periods

name = 'Katrina'
const mortgageCalculator = function(P, I, N) {
return name + ", your monthly rate is $" + monthlyRate().toFixed(2)
}
console.log(mortgageCalculator())
console.log(mortgageCalculator(200000, 0.05, 30))



Expand All @@ -68,6 +109,22 @@ Hint: To drop an interest rate by 5% you can take monthlyRate and multiply it by
*/


const monthlyRateTwo = function(){
return principal * (Math.pow( 1+ monthlyInterestRate, periods)*(monthlyInterestRate) / ((Math.pow(1 + monthlyInterestRate, periods)-1)));
}
console.log(monthlyRateTwo().toFixed(2))

let rate = monthlyRateTwo().toFixed(2)

const score = function(creditScore) {
if (creditScore > 740){
return rate * 0.95;
} else {
return rate *1.05
}
}
console.log(score(850).toFixed(2))



// 🏡 Task 6: Loops
Expand All @@ -86,6 +143,15 @@ For example, variableInterestRate(200000, 0.04, 30) should console.log:
"{Name}, with an interest rate of 0.06, your monthly rate is $1199"
*/

const variableInterestRate = function(I, P, N) {

for(let i = 4; i<13; i++) {
console.log(i * 0.005)
}
return name + ", your monthly rate is $" + rate
}

console.log(variableInterestRate(200000, 0.04, 30))



Expand Down