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

London 9 - Lovelace - Shayan Mahnam - JS-Core-1 - Week 3 - #164

Open
ShayanMahnam wants to merge 4 commits into
CodeYourFuture:mainfrom
ShayanMahnam:main
Open

London 9 - Lovelace - Shayan Mahnam - JS-Core-1 - Week 3#164
ShayanMahnam wants to merge 4 commits into
CodeYourFuture:mainfrom
ShayanMahnam:main

Conversation

@ShayanMahnam

Copy link
Copy Markdown

No description provided.

@jonnywyatt jonnywyatt 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.

Brilliant, some advanced techniques here
It's important that code can be easily read by other developers, so don't do too much in a single line, break it into steps. It's better if the code is slightly longer but more readable.
Well done!

Comment thread 2-mandatory/3-financial-times.js Outdated
*/
function potentialHeadlines(allArticleTitles) {
// TODO
return allArticleTitles.filter(items => items.length < 65);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The instruction asks for 65 characters or less

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed 👍

Comment thread 2-mandatory/3-financial-times.js Outdated
for (let i = 0; i < allArticleTitles.length; i++) {
arr.push(allArticleTitles[i].split(" ").length);
}
return allArticleTitles[arr.indexOf(Math.min(...arr))];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It can be more readable to break it into more lines. eg

const fewestWords = Math.min(...arr)
const indexOfArticle = arr.indexOf(fewestWords)
const articleTitle = allArticleTitles[indexOfArticle]
return articleTitle

Also, this works when all articles have a different number of words. What if two or more articles have the same number of words? arr.indexOf will find the first match.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

looks better now thank you 🥇

Comment thread 2-mandatory/4-stocks.js
Comment thread 2-mandatory/4-stocks.js
Comment thread 3-extra/1-factorial.js Outdated
function factorial(input) {
// TODO
let sum = 1
for (i = 1; i <= input; i++){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Don't forget to initialise i with let

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread 3-extra/2-array-of-objects.js
Comment thread 3-extra/2-array-of-objects.js
@jonnywyatt jonnywyatt added the reviewed A mentor has reviewed this code label Dec 11, 2022
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