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

London10_Jan_Softa_Javascript_Core1_Coursework_Week3 - #235

Open
softacoder wants to merge 13 commits into
CodeYourFuture:mainfrom
softacoder:main
Open

London10_Jan_Softa_Javascript_Core1_Coursework_Week3#235
softacoder wants to merge 13 commits into
CodeYourFuture:mainfrom
softacoder:main

Conversation

@softacoder

Copy link
Copy Markdown

No description provided.

@@ -13,6 +13,16 @@

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.

Looks great!
A small point - keep an eye on indentation, as it will make it easier for other developers to read your code.

Implement the function below, which will return a new array containing only article titles which will fit.
*/

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!
For extra practice, can you re-write this with the filter array method?




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.

This solution will return the title with the fewest characters, but this might be different from the title with the fewest words.
Can you try fixing this? (you only need to make 2 small changes 😄)

// TODO
let newArr = [];
for (let title of allArticleTitles) {
if (/[0-9]/.test(title) === true) {

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.

You can replace this line with if (/[0-9]/.test(title)) {
Can you think of why that is the case?

*/



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 is a nice solution.
Can you think of another way to get the number of articles, without using the numberOfArticles variable?

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

//

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 is a great solution! 👍
I love the use of the extra function here 😄 It makes the code very easy to read and understand.

Comment thread 2-mandatory/3-stocks.js
let arrayWithStrings = [];
for (let i = 0; i < stocks.length; i++) {
let stockOfName = stocks[i].toUpperCase();
let sortedArray = closingPricesForAllStocks[i].sort(function (a, b) {

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 - I think it works.
There are a few other ways to do this as well - have a look at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max

@moneyinthesky moneyinthesky added the reviewed A mentor has reviewed this code label Mar 14, 2023
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.

2 participants