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

London Class 9- Leila Farsani- JavaScript-Core-3-Coursework-Week3 - #163

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

London Class 9- Leila Farsani- JavaScript-Core-3-Coursework-Week3#163
leilafarsani wants to merge 2 commits into
CodeYourFuture:mainfrom
leilafarsani:main

Conversation

@leilafarsani

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.

Wow! Very impressive @leilafarsani
You've taken to Javascript "like a duck to water" (daft english expression 😆 )
Keep pushing your skills, you have a talent for this 👏

}
return even.toString();
}
console.log(evenNumbers());

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 logs out the array fine, looks good.
It's a minor point but the instruction is asking to log it out as a comma-separated string. Have a look at the array.join method.

}
let i = 0;
let even = [];
while (i < 2 * n) {

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!

// TODO
let i = 0;
while (i < birthdays.length) {
if (birthdays[i][1] === "u") {

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 works, but what if later on more birthdays are added to the array including ones in June? Is it a bit more robust and readable to look for the whole word July?

let i = 0;
let sum = n * (n - 1);
do {
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.

This is returning instantly from the evenNumbersSum function, so it only ever executes once. Line 12 (let sum) is working out the total on its own, so there's no need for the loop. Is there a way to work out the total by adding to the total on each iteration of the loop?

// TODO - Write for loop code here

for (i = 0; i < WRITERS.length; i++) {
let text = 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! Also have a look at string templates, see if you prefer that syntax.

Comment thread 2-mandatory/4-stocks.js
total += closingPricesForAllStocks[i][j];
}
let average = total / closingPricesForAllStocks[i].length;
let roundedAverage = Number(average.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.

Nice technique

Comment thread 2-mandatory/4-stocks.js
// TODO
let changeArr=[];
for (let i = 0; i < closingPricesForAllStocks.length; i++){
let change = closingPricesForAllStocks[i][closingPricesForAllStocks.length - 1] - closingPricesForAllStocks[i][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.

This works 👍
It's a little hard to read, eg could break into separate lines:

const prices = closingPricesForAllStocks[i]
const firstPrice = prices[0]
const lastPrice = prices[prices.length - 1]
const change = lastPrice - firstPrice;

Comment thread 2-mandatory/4-stocks.js
// TODO
let maxArray = [];
for (let i = 0; i < closingPricesForAllStocks.length; i++){
let maxStocks = 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.

toFixed returns a string, and Math.max expects a list of numbers

let cookingGenre = [];
let booksArr = [];
for (let i = 0; i < books.length; i++) {
if (books[i].genre === "children") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Works perfectly

cookingGenre.push(books[i]);
}
}
let childrenSorted = childrenGenre.sort((a, b) => a.rating - b.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.

Nice! Also consider

const sorted = childrenGenre.sort().reverse()

@jonnywyatt jonnywyatt added the reviewed A mentor has reviewed this code label Dec 10, 2022
@ghost

ghost commented Dec 16, 2022

Copy link
Copy Markdown

Good Job!

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