Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
index.html
main.js
readme.md

readme.md

Practice: Financial Advisor

From: Nashville Software School

The learning objective for this practice exercise is to use different combinations of object property configurations to understand how you can have control over what data can, and cannot, be changed by other code in an application.

Your job is to create an object that represents a financial advisor and has the following properties and methods.

  1. Company (enumerable, writable, property)
  2. Specialty (enumerable, writable, property)
  3. Name (enumerable, property)
  4. Portfolio (non-enumerable, property) - Should display the stocks the advisor currently holds
  5. Worth (non-enumerable, method)
  6. Purchase (non-enumerable, method) - This method takes a stock ticker symbol, a quantity, and a price as arguments
  7. Sell (non-enumerable, method) - This method takes a stock ticker symbol, a quantity, and a price as arguments

When sell() or purchase() are invoked, then the stock portfolio should be modified accordingly. Start off with making portfolio property an array that holds transactions. Each transaction should be an object.

// Example transaction
{
    stock: "TWTR",
    quantity: 100,
    price: 34.59,
    buyTransaction: true
}

When you invoke the worth() method, it should look at every transaction and calculate the advisor's net worth. Each buy transaction should add to the net worth. Each sell transaction should subtract from the net worth.


Challenges are optional exercises that you should only attempt if you have completed the practice exercises, and fully understand the concepts used in them.

You can’t perform that action at this time.