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

Manchester NW5-Doris Siu-JavaScript1-Week3#124

Open
Doris-Siu wants to merge 5 commits intoCodeYourFuture:mainfrom
Doris-Siu:main
Open

Manchester NW5-Doris Siu-JavaScript1-Week3#124
Doris-Siu wants to merge 5 commits intoCodeYourFuture:mainfrom
Doris-Siu:main

Conversation

@Doris-Siu
Copy link

No description provided.

return sum;
}


Copy link

Choose a reason for hiding this comment

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

I think You need the loop to add up the first n even numbers,
starting at 0. So if n=3, you need to add up 0+2+4. If n=10 you
need to add up 0+2+4+6+8+10+12+14+16+18.

Copy link

@rebwar1 rebwar1 left a comment

Choose a reason for hiding this comment

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

please see my comment

Comment on lines +18 to +23
let arr = [];
for (let item of cities) {
let temp = temperatureService(item);
arr.push (`The temperature in ${item} is ${temp} degrees`);
}
return arr;
Copy link

Choose a reason for hiding this comment

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

really nice solution & use of template literals :) could you think of renaming your arr variable to something more descriptive? For example let cityTemperatures

result = generateRandomNumber();
} while (result <= 50);

return result;
Copy link

Choose a reason for hiding this comment

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

really good use of a do-while loop, well done

let numTitleArr = [];
let conditions = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
for (let title of allArticleTitles) {
if (conditions.some((el) => title.includes(el))) {
Copy link

Choose a reason for hiding this comment

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

this works, but you could use regex so you don't have to type out an array of the conditions :) for example:

 if (/\d/.test(title)) {
      numTitleArr.push(title);
 }

\d is used to test for numbers present - this is a good site for playing around with regex https://regex101.com/

sum += strLength;
}
let average = sum / totalOfArticle;
return Math.round(average);
Copy link

Choose a reason for hiding this comment

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

nice solution!

let averageOfStock = [];
let sum = 0;
for (let item of closingPricesForAllStocks) {
for (let element of item) {
Copy link

Choose a reason for hiding this comment

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

good job using 2 loops here to reach your solution

let priceChange = item[4] - item[0];
let formattedPriceChange = parseFloat(priceChange.toFixed(2));
priceChangeOfStock.push(formattedPriceChange);
priceChange = 0;
Copy link

Choose a reason for hiding this comment

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

no need to set priceChange as 0 here, as priceChange is being defined with each iteration

}

return describingArr;
}
Copy link

Choose a reason for hiding this comment

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

well done on solving this! you could reduce your amount of for loops, by just having one loop which loops through the array of CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS and then uses stocks[i] to select the relevant stock

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