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

Glasgow Class 6 Melese Berehannu JavaScript-Core-1-Coursework-Week3 - #239

Open
Melesegithub wants to merge 2 commits into
CodeYourFuture:mainfrom
Melesegithub:main
Open

Glasgow Class 6 Melese Berehannu JavaScript-Core-1-Coursework-Week3#239
Melesegithub wants to merge 2 commits into
CodeYourFuture:mainfrom
Melesegithub:main

Conversation

@Melesegithub

Copy link
Copy Markdown

js1 week 3

Comment on lines +15 to +19
const arrayOfString = [];
for (let city of cities) {
arrayOfString.push(`The temperature in ${city} is ${temperatureService(city)} degrees`)
}
return arrayOfString;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👏

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like how you have simplified your code Melese. I found it easier to understand.

Comment on lines +9 to +15
const newArray = [];
for (let articleTitle of allArticleTitles){
if (articleTitle.length <= 65){
newArray.push(articleTitle)
}
}
return newArray;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good! Although it's good to try and make variable names reflect what they are doing. For example here, a better name than newArray would have been, potentialHeadlines or similar

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is another good function Melese. Easy for someone else to follow.

Comment on lines +33 to +34
}else{
titleWithFewestWord = titleWithFewestWord;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think we need this else statement here as it's not doing anything. titleWithFewestWord already equals titleWithFewestWord. We can just stick with the if statement only

Comment on lines +46 to +54
const headlinesWithNumber =[];
for (let article of allArticleTitles){
for (let char of article){
if(char.match(/[0123456789]/g)){
headlinesWithNumber.push(article);break;
}
}
}return headlinesWithNumber;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice!

Comment on lines +63 to 68
let averageNumberOfCharacter = 0;
for (let articleTitle of allArticleTitles){
averageNumberOfCharacter = averageNumberOfCharacter + articleTitle.length
}
return Math.round((averageNumberOfCharacter/allArticleTitles.length).toFixed(0))
}

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 thread 2-mandatory/3-stocks.js
Comment on lines +38 to +46
const averagePrices = [];

for (let closingPriceForStock of closingPricesForAllStocks){
averagePrices.push(Number(((closingPriceForStock.reduce((a,b) => a + b, 0))/(closingPriceForStock.length)).toFixed(2)))
}
return averagePrices;

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of reduce 👌

Comment thread 2-mandatory/3-stocks.js
Comment on lines +82 to +85
const priceDescription = [];
for (let i = 0; i < closingPricesForAllStocks.length; i++){
priceDescription.push(`The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${(((closingPricesForAllStocks[i]).sort(function(a,b){return a - b})[closingPricesForAllStocks[i].length-1]).toFixed(2))}`) }
return priceDescription;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is great. The only suggestion I would make is to format your code so that it's easier to read. I think we are going to talk about this in class tomorrow :)

@annacollins85 annacollins85 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 work! You've shown a lot of understanding of arrays here 🙌

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants