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

London10 - Khalil Alhaydr - JavaScript-Core-1-Coursework-Week3 - #241

Open
Khlil1313 wants to merge 14 commits into
CodeYourFuture:mainfrom
Khlil1313:main
Open

London10 - Khalil Alhaydr - JavaScript-Core-1-Coursework-Week3#241
Khlil1313 wants to merge 14 commits into
CodeYourFuture:mainfrom
Khlil1313:main

Conversation

@Khlil1313

Copy link
Copy Markdown

No description provided.

sum += wordCount;
count += 1;
}
let average = sum / count;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

couldnt you use allArticleTitles.length - 1 instead count variable ?


}
return resultArray
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: I saw you and Elena have a similar solution.

I had another solution
function getTemperatureReport(cities) {
const temperatureReport = [];
for(let i = 0; i < cities.length; i++) {
const temperature = temperatureService(cities[i]);
temperatureReport.push(The temperature in ${cities[i]} is ${temperature} degrees);
}
return temperatureReport;
}

}
return articleTitlesLessThan65

}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: Same as mine



}
return shortestTitle

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: I see you use .split which I did not. Well done

count += 1;
}
let average = sum / count;
return Math.round(average);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: Nice

Comment thread 2-mandatory/3-stocks.js
averageArray.push(Math.round(average *100)/100)
sum = 0;
}
return averageArray

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: Nice code!

Comment thread 2-mandatory/3-stocks.js
priceChangeArray.push(Math.round(priceChange * 100) / 100)
}
return priceChangeArray
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: You could also use array in array method.
function getPriceChanges(closingPricesForAllStocks) {
// TODO
let changedPrices = [];
for (let arrayWithPrices of closingPricesForAllStocks) {
let changedPrice = arrayWithPrices[arrayWithPrices.length - 1] - arrayWithPrices[0];
changedPrices.push(Number(changedPrice.toFixed(2)));
}
return changedPrices;
}

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

Well implemented solutions, I've noted a few different ways of approaching some of the problems, however your solutions are very appropriate as well.

}

sayHelloToUser();
sayHelloToUser(); // we didn't insert any input in the function sayHelloToUser()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thought: The function will output the string "Hello undefined" instead of just undefined


function first(arr) {
return; // complete this statement
return arr[0]; // complete this statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thought: This will return undefined if the array is empty.


function last(arr) {
return; // complete this statement
return arr[arr.length - 1]; // complete this statement

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thought: This will return an error if the arr value is not an array

*/

let numbers = [1, 2, 3]; // Don't change this array literal declaration
numbers[3] = 4;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: You could also do

numbers.push(4);

articleTitlesLessThan65.push(article)
}
}
return articleTitlesLessThan65

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This could also be achieved by using a .filter() function

// TODO

let shortestTitle;
// let shortestTitleWordCount = Infinity;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nitpick: Don't leave commented code in your solution


}
return shortestTitle

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nitpick: Don't leave too many blank lines in a function



}
return shortestTitle

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This could also be achieved with a reduce() function.

@moneyinthesky moneyinthesky added the reviewed A mentor has reviewed this code label Mar 17, 2023
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.

5 participants