Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London_10-Saliha_Popal-JavaScript-Core-1-Coursework-Week3 - #231

Open
SalihaPopal wants to merge 3 commits into
CodeYourFuture:mainfrom
SalihaPopal:main
Open

London_10-Saliha_Popal-JavaScript-Core-1-Coursework-Week3#231
SalihaPopal wants to merge 3 commits into
CodeYourFuture:mainfrom
SalihaPopal:main

Conversation

@SalihaPopal

Copy link
Copy Markdown

No description provided.

statement.push(`The temperature in ${city} is ${temperature} degrees`)
}
return statement;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Well done!

Consider: You could also iterate [i]
function getTemperatureReport(cities) {
const temperatureReport = [];
for(let i = 0; i < cities.length; i++) {
const temperature = temperatureService(cities[i]);
temperatureReport.push(The temperature in ${cities[i]} is ${temperature} degrees);
}
return temperatureReport;

}

return fewestWords;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Same code solution as mine

}

return headlinesWithNumbers;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Interesting. I see you used .charAt and NaN. I have not seen any other use it.

My solution:
let newArr = [];
for (let title of allArticleTitles) {
if (/[0-9]/.test(title) === true) {
newArr.push(title);
}
}

return newArr;
}

const averageChars = Math.round(totalChars / allArticleTitles.length);

return averageChars;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: I see you use just 1 global variable (let). Mine has 2. Well done

Comment thread 2-mandatory/3-stocks.js
}

return priceChanges;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Nice solution

Here is one with less code:
function getPriceChanges(closingPricesForAllStocks) {
// TODO
let changedPrices = [];
for (let arrayWithPrices of closingPricesForAllStocks) {
let changedPrice = arrayWithPrices[arrayWithPrices.length - 1] - arrayWithPrices[0];
changedPrices.push(Number(changedPrice.toFixed(2)));
}
return changedPrices;
}

Comment thread 2-mandatory/3-stocks.js
}

return descriptions;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Math.max was a clever solution. New one for me

// TODO
}

function getTemperatureReport(cities){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good 👍
One small suggestion - keep an eye on indentation, as it will make it easier for other developers to read your code.

}

function getTemperatureReport(cities){
const statement = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another small point - is statement a good name for this variable? Maybe statements or weatherReports would be a better name as this is an array which contains many statements 😄

Comment thread 2-mandatory/2-financial-times.js Outdated
// TODO
}

function potentialHeadlines(allArticleTitles) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect!
As an extra exercise - could you re-write this using the filter array method?

Comment thread 2-mandatory/2-financial-times.js Outdated
(you can assume words will always be seperated by a space)
(you can assume words will always be separated by a space)
*/
function titleWithFewestWords(allArticleTitles) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this solution will give you the title with the fewest characters, but this might not be the fewest words.
With a couple of small changes you could fix this 😄

Implement the function below to return this number - rounded to the nearest integer.
*/

function averageNumberOfCharacters(allArticleTitles) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice solution!

Comment thread 2-mandatory/3-stocks.js
@@ -34,8 +34,24 @@ const CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS = [
Functions can help with this!
*/
function getAveragePrices(closingPricesForAllStocks) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on this one 👍

Comment thread 2-mandatory/3-stocks.js
The stock ticker should be capitalized.
The price should be shown with exactly 2 decimal places.
*/
function highestPriceDescriptions(closingPricesForAllStocks, stocks) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of Math.max here!

// `getStations` goes here


function getStations() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks perfect!
For practice, you could try re-writing this with the filter array method.

@moneyinthesky

Copy link
Copy Markdown
Contributor

Great job on this coursework! Well done.

@moneyinthesky moneyinthesky added the reviewed A mentor has reviewed this code label Mar 14, 2023
@SalihaPopal SalihaPopal added the review requested I would like a mentor to review my PR label Mar 21, 2023

// Using the filter function without loops


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks perfect, well done 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

review requested I would like a mentor to review my PR reviewed A mentor has reviewed this code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants