-
-
Notifications
You must be signed in to change notification settings - Fork 279
WM4-Vanipriya_Piramanathan-JavaScript Core 1-Week-3 #91
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,14 @@ const BIRTHDAYS = [ | |
| "September 28th", | ||
| "November 15th" | ||
| ]; | ||
|
|
||
| function findFirstJulyBDay(birthdays) { | ||
| // TODO | ||
| let i=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. Hi, Piramanathan, I check your code and it is fine, it's functional. good job |
||
| while(i<birthdays.length){ | ||
| if(birthdays[i].includes("July")){ | ||
| return birthdays[i]; | ||
| } | ||
| 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. Good |
||
| } | ||
|
|
||
| console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,13 @@ | |
| */ | ||
|
|
||
| function evenNumbersSum(n) { | ||
| // TODO | ||
| let i=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. Great job!!! |
||
| let sumOfEven=0; | ||
| do{ | ||
| sumOfEven=sumOfEven+i*2; | ||
| i++; | ||
| }while(i<n) | ||
| return sumOfEven; | ||
|
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 codes. You can also do it this way |
||
| } | ||
|
|
||
| console.log(evenNumbersSum(3)); // should output 6 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,15 @@ const CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS = [ | |
| Functions can help with this! | ||
| */ | ||
| function getAveragePrices(closingPricesForAllStocks) { | ||
| // TODO | ||
| let average=[]; | ||
| for(let i=0; i<closingPricesForAllStocks.length; i++){ | ||
| let sum=0; | ||
| for(let j=0; j<closingPricesForAllStocks[i].length; j++){ | ||
| sum=sum+closingPricesForAllStocks[i][j]; | ||
| } | ||
| average.push(parseFloat((sum/closingPricesForAllStocks[i].length).toFixed(2))); | ||
| } | ||
| return average; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -48,7 +56,11 @@ 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 priceChange=[]; | ||
| for(let i=0; i<closingPricesForAllStocks.length; i++){ | ||
| priceChange.push(parseFloat((closingPricesForAllStocks[i][4]-closingPricesForAllStocks[i][0]).toFixed(2))); | ||
| } | ||
| return priceChange; | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -64,7 +76,11 @@ function getPriceChanges(closingPricesForAllStocks) { | |
| The price should be shown with exactly 2 decimal places. | ||
| */ | ||
| function highestPriceDescriptions(closingPricesForAllStocks, stocks) { | ||
| // TODO | ||
| let highestPrice=[]; | ||
| for(let i=0; i<closingPricesForAllStocks.length; i++){ | ||
| highestPrice.push(`The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${(Math.max.apply(Math,closingPricesForAllStocks[i])).toFixed(2)}`) | ||
| } | ||
| return highestPrice; | ||
| } | ||
|
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. Good job Vanipriya |
||
|
|
||
|
|
||
|
|
||
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 explanations