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

ZA2 - Anthony Mogotlane - JavaScript-Core-1-Coursework - W3 - #53

Open
AnthonyMogotlane wants to merge 6 commits into
CodeYourFuture:mainfrom
AnthonyMogotlane:main
Open

ZA2 - Anthony Mogotlane - JavaScript-Core-1-Coursework - W3#53
AnthonyMogotlane wants to merge 6 commits into
CodeYourFuture:mainfrom
AnthonyMogotlane:main

Conversation

@AnthonyMogotlane

Copy link
Copy Markdown

No description provided.

@dschouw-CYF dschouw-CYF 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.

Thank you for your submission Anthony, awesome work!


function evenNumbers(n) {
// TODO
let res = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nicely done Anthony!


function getTemperatureReport(cities) {
// TODO
return cities.map(town => `The temperature in ${town} is ${temperatureService(town)} 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.

Nice use of .map() 👍


function getRandomNumberGreaterThan50() {
// TODO - implement using a do-while loop
let rand = generateRandomNumber();

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 function getRandomNumberGreaterThan50() invokes generateRandomNumber() only once.
The do/while loop then executes until the result of the generateRandomNumber() returns a value greater than zero.
Will the do/while loop ever complete?

*/
function potentialHeadlines(allArticleTitles) {
// TODO
return allArticleTitles.filter(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.

Good use of .filter().
Filter is a predicate function , so you can also just return the result of a boolean evaluation and it should still work.
Well done

*/
function titleWithFewestWords(allArticleTitles) {
// TODO
let num = Math.min(...allArticleTitles.map(title => title.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.

This is pretty cool, well done

Comment thread 2-mandatory/4-stocks.js
*/
function getAveragePrices(closingPricesForAllStocks) {
// TODO
return closingPricesForAllStocks.map(priceArr => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Concise, I like it!

Comment thread 2-mandatory/4-stocks.js
return `The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${Math.max(...priceArr).toFixed(2)}`;
})
}
console.log(highestPriceDescriptions(CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS, STOCKS));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really well done on your solutions for this exercise Anthony 🔥

Comment thread 3-extra/1-factorial.js
Using a loop, complete the function below so it returns the factorial of the number being passed in.
*/

// Solved it using recursion instead of a loop

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👀 Much more elegant than the official solution 🤣

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