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

London-Class10-Bedrije Omuri- Javacript-1-WeekIII - #221

Open
Bedi06 wants to merge 6 commits into
CodeYourFuture:mainfrom
Bedi06:main
Open

London-Class10-Bedrije Omuri- Javacript-1-WeekIII#221
Bedi06 wants to merge 6 commits into
CodeYourFuture:mainfrom
Bedi06:main

Conversation

@Bedi06

@Bedi06 Bedi06 commented Mar 1, 2023

Copy link
Copy Markdown

No description provided.


function getTemperatureReport(cities) {
// TODO
const weather = [];

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.

Great job on this one 😄

// TODO
headlines = []; // we declare an empty array so when we get the headlines with length<=65 we push them here

for (article of allArticleTitles) { // we loop through all articles and check their length

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.

Small suggestion: it is usually a good idea to declare the variable in the for loop with let or const:
for (const article of allArticleTitles) {

(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.

Nice solution 👍

*/
function headlinesWithNumbers(allArticleTitles) {
// TODO
function withNumber(title) {

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.

I like that you've put the withNumber logic into its own function 👍
It might be worth defining the withNumber function outside of the headlinesWithNumbers function - so it can potentially be re-used. But not a big deal!

The Financial Times wants to understand what the average number of characters in an article title is.
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.

Looks perfect - nice work 😄

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

let averagePrices = [];
for (prices of 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.

Same comment as above about using let or const in the for loop.

Comment thread 2-mandatory/3-stocks.js
for (prices of closingPricesForAllStocks) {
sum = 0;
for (item of prices) { //we use for within for so we can access the arrays of the array
sum += parseFloat(item);

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.

Might be worth double-checking - is item already a Number? If it is, we may not need parseFloat here.

Comment thread 2-mandatory/3-stocks.js
*/
function getPriceChanges(closingPricesForAllStocks) {
// TODO
return closingPricesForAllStocks.map(prices => { // we use the map method to intenerate each element of closingPricesForAllStock

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 and short implementation 😄
Again, you might need the parseFloat on lines 74 and 75.

Comment thread 2-mandatory/3-stocks.js
*/
function highestPriceDescriptions(closingPricesForAllStocks, stocks) {
// TODO
return stocks.map((ticker, index) => { //map method makes it shorter to intenerate through each element of stocks by corresponding the index with the ticker and generate a new array

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.

Great work on this one!

@moneyinthesky

Copy link
Copy Markdown
Contributor

Great job on this coursework @Bedi06 👍

@moneyinthesky moneyinthesky added the reviewed A mentor has reviewed this code label Mar 14, 2023

@PaulinaWywrot PaulinaWywrot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job Bedi, I like your way of writing the code :)

Comment on lines +16 to 25
for (const city of cities) {
const temperature = temperatureService(city);
if (temperature !== undefined) {
const statement = `The temperature in ${city} is ${temperature} degrees`;
weather.push(statement);
}
}

return weather;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

spot on! very clear and concise code :)

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

Labels

reviewed A mentor has reviewed this code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants