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

JavaScript-core-1-Coursework-week3 Ebrahim Beiati-Asl - #188

Open
ebrahimbeiati wants to merge 1 commit into
CodeYourFuture:mainfrom
ebrahimbeiati:main
Open

JavaScript-core-1-Coursework-week3 Ebrahim Beiati-Asl#188
ebrahimbeiati wants to merge 1 commit into
CodeYourFuture:mainfrom
ebrahimbeiati:main

Conversation

@ebrahimbeiati

Copy link
Copy Markdown

Please review my homework and tell me if you see any mistake.

Please review my homework and tell me if you see any mistake.
@Roozbehshokri1990

Copy link
Copy Markdown

perfect code, nice

@JDysiewicz JDysiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall really good, well done @ebrahimbeiati :)

Comment on lines +11 to 16
while (i<=n){
if(i%2==0)
i++;

}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right idea, but you've created an infinite loop here (while i<=n but you only increment i if i%2===0, so when it reaches i=1 you infinitely loop.

What you need is two variables; one to increment on every iteration up to n, and one hold the even numbers

const evenNums = []
let i = 0
while (evenNums.length < n) {
   if(i % 2 === 0) {
      evenNums.push(i)
   }
   i++
}
return evenNums

// TODO
let i = 0;
while (i < birthdays.length) {
if (birthdays[i].includes("July")) return birthdays[i];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is all good, but try to make sure to include {} for if statements, even if they're one line (keeps things consistent)


do {
if (counter % 2 === 0) {
sum = sum + counter;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this can be cleaned up by using the += operator; sum += counter

Comment on lines -22 to +38
let temparatureMap = new Map();

temparatureMap.set('London', 10);
temparatureMap.set('Paris', 12);
temparatureMap.set('Barcelona', 17);
temparatureMap.set('Dubai', 27);
temparatureMap.set('Mumbai', 29);
temparatureMap.set('São Paulo', 23);
temparatureMap.set('Lagos', 33);
return temparatureMap.get(city);
let temparatureMap = new Map();

temparatureMap.set("London", 10);
temparatureMap.set("Paris", 12);
temparatureMap.set("Barcelona", 17);
temparatureMap.set("Dubai", 27);
temparatureMap.set("Mumbai", 29);
temparatureMap.set("São Paulo", 23);
temparatureMap.set("Lagos", 33);

return temparatureMap.get(city);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

think your formatter settings conflict with the repo here ; is not a huge deal but something to watch out for

*/
function potentialHeadlines(allArticleTitles) {

return allArticleTitles.filter(items=> items.length < 65);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice use of an arrow function! although to be a bit cleaner the items parameter should probable be called title instead

Comment thread 2-mandatory/4-stocks.js
for (let price of newPrice) {
sum += price;
}
const average = sum / newPrice.length;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what if newPrice is an empty array?

Comment thread 3-extra/1-factorial.js
Comment on lines 11 to 17
function factorial(input) {
let sum = 1;
for (i = 1; i <= input; i++) {
sum *= i;
}
return sum;
// TODO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good to see you doing the extra ones! :)

@JDysiewicz JDysiewicz added the reviewed A mentor has reviewed this code label Dec 13, 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.

3 participants