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

finishing all mandatory #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

finishing all mandatory #261

wants to merge 1 commit into from

Conversation

Shadi38
Copy link

@Shadi38 Shadi38 commented Mar 9, 2023

No description provided.

@@ -5,16 +5,43 @@
Implement the function below, which will return a new array containing only article titles which will fit.
*/
function potentialHeadlines(allArticleTitles) {
// TODO
}
const newarray = [];

Choose a reason for hiding this comment

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

what is the purpose of the const 'newarray'?

let finalTitle=ARTICLE_TITLES[0];
let i=1;

while(i<ARTICLE_TITLES.length){

Choose a reason for hiding this comment

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

In this while loop, you are using 'i' as an iterator to go on loop until it reaches the condition i < ARTICLE_TITLES.length.

Is there another way to improve this loop so it's more clear what it's doing?

Copy link
Author

Choose a reason for hiding this comment

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

while(i=1, i<ARTICLE_TITLES.length, i++)

const newarray=[];
const number=/[0-9]/;
let i=0;
while (i < allArticleTitles.length) {

Choose a reason for hiding this comment

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

Same as the previous comment from the while loop

}


Choose a reason for hiding this comment

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

Just as a nice to have: try to avoid committing unnecessary empty lines like this so we can keep the Pull request cleaner and avoid extra changes

Copy link
Author

Choose a reason for hiding this comment

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

you are right, thanks for your advice

// TODO
let sum=0;
for (const item of allArticleTitles) {
sum = (item.length)+sum;

Choose a reason for hiding this comment

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

why is item.length to be inside the () ?
is there another way to do a 'sum = variable + sum'? a shorter way?

Copy link
Author

Choose a reason for hiding this comment

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

sum += item.length


let FirstPrice = stocksline[0];
let i = 1;
while(i<stocksline.length){

Choose a reason for hiding this comment

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

Same comment for the while loop as before

Copy link
Author

Choose a reason for hiding this comment

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

while(i=1, i<stocksline.length, i++){ }

Copy link

@AndriusIsin AndriusIsin left a comment

Choose a reason for hiding this comment

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

Good job Shadi !

const citystrings = [];

for (const item of cities) {
citystrings.push(

Choose a reason for hiding this comment

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

Will be nice to see there String Interpolation👌

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with that 😄 You can read more about template literals in JavaScript here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

@@ -23,15 +50,45 @@ function titleWithFewestWords(allArticleTitles) {
(Hint: remember that you can also loop through the characters of a string if you need to)
*/
function headlinesWithNumbers(allArticleTitles) {
// TODO
const newarray=[];
const number=/[0-9]/;

Choose a reason for hiding this comment

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

I see array like this for the first time, can you explain what it does ? I'm just curious 🙂

Copy link
Author

Choose a reason for hiding this comment

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

it means that it is(number) integer and it is not a letter or sth else

}
const newarray = [];

for (const item of allArticleTitles) {

Choose a reason for hiding this comment

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

Nice !

@moneyinthesky moneyinthesky added bug Something isn't working reviewed A mentor has reviewed this code and removed bug Something isn't working labels Mar 15, 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.

4 participants