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

London Class 8 - Hatice Aydogan- JS Core 1 Coursework - Week 3 - #23

Open
Hatice06 wants to merge 3 commits into
CodeYourFuture:mainfrom
Hatice06:main
Open

London Class 8 - Hatice Aydogan- JS Core 1 Coursework - Week 3#23
Hatice06 wants to merge 3 commits into
CodeYourFuture:mainfrom
Hatice06:main

Conversation

@Hatice06

Copy link
Copy Markdown

No description provided.


// TODO - Write for loop code here
for(i = 0; i < WRITERS.length; i++){
console.log(`${WRITERS[i]} is ${AGES[i]} years old`)

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 use of interpolation!

// } else {
// return acc;
// }
// }, "");

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! Just one minor detail, it may be best to remove commented out code in order to find the relevant code faster and easier.

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

Super job, well done. It's great to see you using so many array methods already.

};
i++
} while (count < n);
return sum;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

well done, this was difficult. If you check the solutions you can see how you can do this with only sum and i variables

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.

Thanks Ellie, I checked the solution and I changed my solution with sum and i variables.

let currentCity = cities[i];
let currentCityTemperature = temperatureService(currentCity);
cityWithTemperature.push(
`The temperature in ${currentCity} is ${currentCityTemperature} degrees`

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

*/
function potentialHeadlines(allArticleTitles) {
// TODO
let titlesMoreThan65Char = allArticleTitles.filter(

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 use of filter. You can also do this with a loop but it's great you're practising array methods :)

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.

Thanks Ellie, I did it with for loop again.

title.split("").forEach((character) => {
if (numbers.includes(character)) {
titlesToReturn.push(title);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

wow, well done for using string & array methods. You can also do this with for loops, but array methods are more commonly used, so this is excellent work

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.

Thanks Ellie, we did this together with the TA in the homework club. I tried to do this with loops as a second solution.

let totalCharacterNumber = 0;
for (let i = 0; i < allArticleTitles.length; i++) {
totalCharacterNumber =
totalCharacterNumber + allArticleTitles[i].split("").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.

remember you can use .length on a string too, so you don't need to split the string

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.

Thanks Ellie, I removed split.

// }, "");
let shortestTitle = allArticleTitles[0];
for (let i = 1; i < allArticleTitles.length; i++) {
if (allArticleTitles[i].split("").length < shortestTitle.split("").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.

the test for this passes because the title with the shortest number of words is also the title with the fewest characters.
Can you tell what needs to change in order to check which title has the fewest words? Hint: what's the difference between

allArticleTitles[i].split("").length

and

allArticleTitles[i].split(" ").length

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.

Hi Ellie, the first one takes all the characters of the array as one item, therefore the length of the array is equal to the number of the characters including spaces. The second one is taking all the words in the array as an item, therefore the number of the words is the length of the array. I changed mine to the second one.

Comment thread 2-mandatory/4-stocks.js
let salesAveragePrices = []
for(let i = 0; i <closingPricesForAllStocks.length; i++){
let eachCompanySalesTotal = 0;
for(let j = 0; j < closingPricesForAllStocks[i].length; j++){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

well done! This was tough. When you look at the solutions, think about how you can break this down into smaller problems and functions

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.

Thanks Ellie, I checked the solution document, you are right the solution is clear and easier to understand than mine.

Comment thread 2-mandatory/4-stocks.js
// TODO
let highestPriceByCompany = [];
for( let i = 0; i < closingPricesForAllStocks.length; i++ ){
let highestPrice = Math.max(...closingPricesForAllStocks[i]).toFixed(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

wow well done for finding Math.max to make life easier :)

Comment thread 3-extra/1-factorial.js
total = total * i
}
return total;
}

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!

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