This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 279
Glasgow 6 - Hussein Al-Sayed - JS1 week3 #237
Open
hussein-alsayed
wants to merge
14
commits into
CodeYourFuture:main
Choose a base branch
from
hussein-alsayed:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f82b563
mandadory 1 solved
hussein-alsayed ab32560
task 1 of mandatory 2 solved
hussein-alsayed 6f50b2c
mandatory 2 completed
hussein-alsayed 9e5e2f5
mand3 task1
hussein-alsayed e1fbcd3
mand3 task 2
hussein-alsayed 5da1be3
mand3 task 3 1st attempt
hussein-alsayed 195b15c
mand3 task3 2nd attempt
hussein-alsayed 96101ca
few more attempts
hussein-alsayed 527c5c1
linking worked, decimal issues
hussein-alsayed edcd64e
cleared up from etra comments
hussein-alsayed 1efeab2
Update 2-mandatory/2-financial-times.js
hussein-alsayed 8b64044
minor identation fixes, and couple exercise solution updates
hussein-alsayed 6e209d8
decimal place issue fixed
hussein-alsayed 66c47e7
comment added
hussein-alsayed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,22 @@ const CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS = [ | |
| Functions can help with this! | ||
| */ | ||
| function getAveragePrices(closingPricesForAllStocks) { | ||
| // TODO | ||
| let averagePrices = []; | ||
|
|
||
| for (const stock of CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation is off in multiple places in this loop. Keeping them properly aligned makes it easier to see the flow of the code. Your IDE can help you with that, most also contain a hotkey to auto-indent and fix other styling issues |
||
| let pricesTotal = 0; | ||
|
|
||
| for (const prices of stock){ | ||
|
|
||
| pricesTotal += prices; | ||
| } | ||
|
|
||
| let averagePrice = Number((pricesTotal / stock.length).toFixed(2)); | ||
| averagePrices.push(averagePrice); | ||
| } | ||
|
|
||
|
|
||
| return averagePrices; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -48,7 +63,13 @@ function getAveragePrices(closingPricesForAllStocks) { | |
| The price change value should be rounded to 2 decimal places, and should be a number (not a string) | ||
| */ | ||
| function getPriceChanges(closingPricesForAllStocks) { | ||
| // TODO | ||
| const priceChanges = []; | ||
|
|
||
| for (const stock of CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS){ | ||
| let priceChange = Number((stock[4] - stock[0]).toFixed(2)); | ||
| priceChanges.push(priceChange); | ||
| } | ||
| return priceChanges; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -63,8 +84,32 @@ function getPriceChanges(closingPricesForAllStocks) { | |
| The stock ticker should be capitalised. | ||
| The price should be shown with exactly 2 decimal places. | ||
| */ | ||
|
|
||
| function highestPriceDescriptions(closingPricesForAllStocks, stocks) { | ||
| // TODO | ||
| const highestPriceReports = []; | ||
| let pricesArray = 0; | ||
|
|
||
|
|
||
| for (const stock of stocks){ | ||
| let highestPrice = 0; | ||
| let stockPrices = CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS[pricesArray]; | ||
|
|
||
| for (const price of stockPrices){ | ||
|
|
||
| if (price > highestPrice){ | ||
| highestPrice = price; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // highestPrice = Number(highestPrice.toFixed(2)); | ||
| //(Number object switchh the value from "string" to numbers, which don't see the onely zero at the decimal place as a number then). | ||
| highestPriceReports.push(`The highest price of ${stock.toUpperCase()} in the last 5 days was ${highestPrice.toFixed(2)}`); | ||
| pricesArray++; | ||
|
|
||
| } | ||
|
|
||
| return highestPriceReports; | ||
| } | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.