Fork and clone this project.
Open the foreclosure.js file in your editor.
Run gulp watch to auto-run tests.
Follow the instructions below, and every time you see this symbol 
Use strict mode for this exercise.
- Declare a variable named steve.
- Declare a variable named stevesLoan.
- Declare a variable named month, with an initial value of 0.
- Declare a variable named monthsUntilEvicted.
Declare a function named loan() that takes 0 arguments
Write the following statements inside the loan() function block
- Declare a variable named
account, with an initial value being a literal object having the following properties and values:
- key :
borrowed, value :550000 - key :
balance, value :286000 - key :
monthlyPayment, value :1700 - key :
defaulted, value :0 - key :
defaultsToForeclose, value :5 - key :
foreclosed, value :false
- Declare a function named
missPaymentthat takes0arguments.
- Access the
defaultedproperty of theaccountvariable and increase it's value by1. - Write a conditional that, when the value of
account.defaultedis greater than or equal toaccount.defaultsToForeclose, will run the following statement:- set the value of the
foreclosedproperty of theaccountobject totrue
- set the value of the
- returns a literal object with the following properties:
- key :
getBalance, value : an unnamed function expression that takes0arguments. - key :
receivePayment, value : an unnamed function expression that takes1argument namedamount. - key :
getMonthlyPayment, value : an unnamed function expression that takes0arguments. - key :
isForeclosed, value : an unnamed function expression that takes0arguments.
Declare a function named borrower() that takes 1 argument named loan
Write the following statements inside the borrower() function block
- Declare a variable named
account, with an initial value being a literal object having the following properties and values:
- key :
monthlyIncome, value :1350 - key :
funds, value :2800 - key :
loan, value :loan
- returns a literal object with the following properties:
- key :
getFunds, value : an unnamed function expression that takes0arguments. - key :
makePayment, value : an unnamed function expression that takes0arguments.- Conditionally perform either block of statements
- if
account.fundsis greater than the value of the loan's monthly payment - otherwise
- if
- Conditionally perform either block of statements
- key :
payDay, value : an unnamed function expression that takes0arguments.
- Invoke the
loanfunction and assign it's return value to the variablestevesLoan. - Invoke the
borrowerfunction passing in the argumentstevesLoanand assign it's return value to the variablesteve. - Create a
whileloop that runs the following statement whilesevesLoanis not foreclosed:
All tests should be passing.
The value of monthsUntilEvicted should be 13.
You can tweak some of hardcoded private values such as loan account.monthlyPayment and borrower account.monthlyIncome a little to inspect the different possible outcomes. however, be careful! if the house never goes into foreclosure, you will encounter an endless loop.
Adjust the while loop to also exit when the house has been paid off.
Copyright (c) 2015 Dev League. Licensed under the MIT license.
