-
-
Notifications
You must be signed in to change notification settings - Fork 283
finishing all mandatory #261
base: main
Are you sure you want to change the base?
Conversation
@@ -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 = []; |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
} | ||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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++){ }
There was a problem hiding this 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( |
There was a problem hiding this comment.
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👌
There was a problem hiding this comment.
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]/; |
There was a problem hiding this comment.
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 🙂
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice !
No description provided.