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

London 9 Turing- Farnoosh Moayeri- JavaScript- Week 3 - #205

Open
Farnooshmo wants to merge 12 commits into
CodeYourFuture:mainfrom
Farnooshmo:main
Open

London 9 Turing- Farnoosh Moayeri- JavaScript- Week 3#205
Farnooshmo wants to merge 12 commits into
CodeYourFuture:mainfrom
Farnooshmo:main

Conversation

@Farnooshmo

Copy link
Copy Markdown

No description provided.

@Farnooshmo

Copy link
Copy Markdown
Author

@qingwei91 Hi Qing, Could you review this homework, please? Thank you in advance:)

@qingwei91
qingwei91 self-requested a review December 31, 2022 22:49

@qingwei91 qingwei91 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, I left a few comments

arr.push(i * 2);
i++;
}
console.log(arr.join());

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 one 👍

function potentialHeadlines(allArticleTitles) {
// TODO
newArticleArray =[];
for(let title of allArticleTitles){

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 impl is correct, but you can try to implement it in a simpler way using Array filter method

*/
function titleWithFewestWords(allArticleTitles) {
// TODO
let shortestTitle = allArticleTitles[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.

Hint, you might be able to implement this using sorting algorithm, available in Array

// TODO
}
let newArrayOfHeadlines = [];
for(let allTitles of allArticleTitles){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similarly, you can try to use Array.filter to implement this

Comment thread 2-mandatory/4-stocks.js Outdated
for(let price of closingPrices){
sum += price;
}
let averagePrice = sum / closingPrices.length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you try to factor the calc of average price into a function?

Comment thread 2-mandatory/4-stocks.js
// TODO
let priceChanges = [];
for(let closingPrices of closingPricesForAllStocks){
let priceChange = closingPrices[closingPrices.length - 1] -closingPrices[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.

Likewise, can you try to factor out this into a function?

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.

I have updated it.

const highestRated = [];
for(let book of books){
const {title, genre, rating} = book;
if(!highestRated[genre] || rating > highestRated[genre].rating){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmm, is highestRated[genre] correct?

is highestRated an array or object?

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.

2 participants