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
WM4 - class 1 - Simeon Bikov - JS - week 3 #108
Open
simeonbikov
wants to merge
15
commits into
CodeYourFuture:main
Choose a base branch
from
simeonbikov: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
15 commits
Select commit
Hold shift + click to select a range
5ec7775
completed exercise B
simeonbikov f6dce58
exercises C, D
simeonbikov dcac096
exercises E
simeonbikov 64b5ff8
exercises F & A
simeonbikov f43bd70
completed mandatory-1 exercise
simeonbikov 8cd3306
completed mandatory-2
simeonbikov f388900
mandatory-2
simeonbikov 318294e
mandatory-3
simeonbikov f69e67e
completed mandatory exercises
simeonbikov 0ab9070
cextra-1
simeonbikov 71b0f0d
mandatory-2
simeonbikov 6f94bc6
extra-3
simeonbikov 663f29e
fixed
simeonbikov 3febf4e
fixed mand-3
simeonbikov b4dfcd6
fixed some pieces of code after rewiev
simeonbikov 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "type": "pwa-chrome", | ||
| "request": "launch", | ||
| "name": "Launch Chrome against localhost", | ||
| "url": "http://localhost:8080", | ||
| "webRoot": "${workspaceFolder}" | ||
| } | ||
| ] | ||
| } |
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
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
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
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,19 @@ const CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS = [ | |
| Functions can help with this! | ||
| */ | ||
| function getAveragePrices(closingPricesForAllStocks) { | ||
| // TODO | ||
| let allAveragePrices = []; | ||
|
|
||
| for (const closingPricesForStock of closingPricesForAllStocks) { | ||
| let sum = 0; | ||
| let average = 0; | ||
|
|
||
| for (const price of closingPricesForStock) { | ||
| sum += price; | ||
| } | ||
| average = sum / closingPricesForStock.length; | ||
| allAveragePrices.push(parseFloat(average.toFixed(2))); | ||
| } | ||
| return allAveragePrices; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -48,7 +60,18 @@ 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 | ||
| let changeInPrice = []; | ||
| let firstPrice = 0; | ||
|
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. What is the benefit of defining these variables outside of the for loop? |
||
| let lastPrice = 0; | ||
| let difference = 0; | ||
|
|
||
| for (const closingPricesForStock of closingPricesForAllStocks) { | ||
| firstPrice = closingPricesForStock[0]; | ||
| lastPrice = closingPricesForStock[closingPricesForAllStocks.length - 1]; | ||
| difference = lastPrice - firstPrice; | ||
| changeInPrice.push(parseFloat(difference.toFixed(2))); | ||
| } | ||
| return changeInPrice; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -64,7 +87,15 @@ function getPriceChanges(closingPricesForAllStocks) { | |
| The price should be shown with exactly 2 decimal places. | ||
| */ | ||
| function highestPriceDescriptions(closingPricesForAllStocks, stocks) { | ||
| // TODO | ||
| let highestPriceForAllStock = []; | ||
| let highestPrice = 0; | ||
|
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. What's the benefit of defining this variable outside of the for loop? |
||
|
|
||
| for (let i = 0; i < closingPricesForAllStocks.length; i++) { | ||
| highestPrice = Math.max(...closingPricesForAllStocks[i]); | ||
|
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. Nice use of the spread operator 👍 |
||
| highestPrice = highestPrice.toFixed(2); | ||
| highestPriceForAllStock[i] = `The highest price of ${stocks[i].toUpperCase()} in the last ${closingPricesForAllStocks.length} days was ${highestPrice}`; | ||
| } | ||
| return highestPriceForAllStock; | ||
| } | ||
|
|
||
|
|
||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice usage of
.filter()👍