JavaScript Fundamentals: Console Finances
In this challenge, you'll be using the concepts you've learned to complete the required activity. This activity presents a real-world situation in which your newfound JavaScript skills will come in handy. You are tasked with creating code for analyzing the financial records of a company. You have been provided with a financial dataset in the starter/index.js
file.
You have been given a dataset composed of arrays with two fields, Date and Profit/Losses.
Your task is to write JavaScript code that analyzes the records to calculate 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.
- You will need to track what the total change in profits are from month to month and then find the average.
- (
Total/Number of months
)
-
The greatest increase in profits (date and amount) over the entire period.
-
The greatest decrease in losses (date and amount) over the entire period.
When you open your code in the browser your resulting analysis should look similar to the following:
Financial Analysis
----------------------------
Total Months: 25
Total: $2561231
Average Change: $-2315.12
Greatest Increase in Profits: Feb-2012 ($1926159)
Greatest Decrease in Profits: Sep-2013 ($-2196167)
Your final code should print the analysis to the console.
Financial Analysis
------------------------------------------------------------------------
Total Months: 86
Total: $38,382,578.00
Average Change: -$2,315.12
Greatest Increase in Profits: Feb-2012 ($1,926,159.00)
Greatest Decrease in Profits: Sep-2013 (-$2,196,167.00)
------------------------------------------------------------------------
- Solution URL: https://github.com/technoveltyco/bootcamp-week4-challenge
- Live Site URL: https://technoveltyco.github.io/bootcamp-week4-challenge/
I used
- Semantic HTML5 markup
- CSS custom properties
- Vanilla JavaScript
A good understanding on how to use string formatter to output numbers with thousands and decimals, and include their currencies following the internationalization standards.
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});
const str = formatter.format(1500);
console.log(str)
- Improve the UX/UI creating a website to display the financial analysis.
- Create CRUD features to operate with the dataset.
- Create an API to decouple data from presentation.
- MDN Reference - main reference for depper understanding of the semantic HTML, advanced CSS properties, and advanced JavaScript.
- W3C School HTML Tutorial - alternative reference for semantic and accessible HTML code snippets.
- W3C School CSS Tutorial - It helped as a reference for css properties.
- W3C School JavaScript Tutorial - A quick reference for Math functions and code snippets.
- How to Format Numbers as a Currency String in JavaScript? Useful resource to understand about string formatters, and specifically to format numbers as currencies.
- Rate of Change Definition, Formula, and Importance resource to undertand how to calculate the average rate of change displayed in the financial analysis.
Daniel Rodriguez
- GitHub - Technoveltyco
The teacher and TAs that help us with resources and support to my questions during the development of this challenge.