This is JavaScript code for analyzing the financial records of a company, containing month/year and the amount.
It calculates each of the following:
-
The total number of months included in the dataset.
-
The net total amount of Profit/Losses over the entire period.
-
The average of the changes in Profit/Losses over the entire period:
- Calculated by finding the change in profits from month to month and then the average of that
-
The greates increase in profit (date and amount) over the entire period
-
The greatest decrease in losses (date and amount) over the entire period
The final code prints the analysis to browser console, as below:
Financial Analysis
Total Months: 86
Total: $38382578
Average Change: $-2315.12
Greatest Increase in Profits: Feb-2012 ($1926159)
Greatest Decrease in Profits: Sep-2013 ($-2196167)
-
Click on this link to access the Live Server: Console Finances
-
Press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, ChromeOS) to open the Console
- Pseudocode written first and is also visible in the comments sections throughout my code
- Code brokend down in smaller sections initially and then joined together
- Console.log used throughout to test the output
- Searate for loops used for average changes, max profit and max loss but refactored when completed
- JavaScript
- For loop iteration through nested array
- Selection of the appropriate array elements and performing neccessary operations
- separate for loops used initially for total average change, max profit and max loss but refactored when completed
©️ Helena Gilja
- GitHub - cyberrie
N/A