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

NW5-Mamadou-Barry-JavaScript-Week3 - #134

Open
Barryeasy90 wants to merge 1 commit into
CodeYourFuture:mainfrom
Barryeasy90:main
Open

NW5-Mamadou-Barry-JavaScript-Week3#134
Barryeasy90 wants to merge 1 commit into
CodeYourFuture:mainfrom
Barryeasy90:main

Conversation

@Barryeasy90

Copy link
Copy Markdown

All compile and pass except the function "titleWithFewestWords"

All compile and pass except the function "titleWithFewestWords"

@MustafaAcar-sys MustafaAcar-sys 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.

Hi, Barry, I could not check your code in detail but it seems you have done it. Congrats.

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

Overall great job my friend keep trying :)

// TODO
}
if (cities === []) { // TODO
return [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't even need the check for empty array because it will return empty anyways if its passed as empty array

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you @AltomHussain. yes you are right

let headlineOnNumber = [];
for (let i = 0; i < allArticleTitles.length; i++){// TODO
for (let loopOnElement of allArticleTitles[i]){
if ( loopOnElement === "$"){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is anthor simpler way of checking if a string contains number, using rejex check this out:

  let NewArr = [];
  for (let index = 0; index < allArticleTitles.length; index++) {
    if (/\d/.test(allArticleTitles[index]))
      NewArr.push(allArticleTitles[index]);
  }
  return NewArr;
}```


In your case, you are checking `$` sign but that might change I mean you might have a number without `$` so .....


Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes you are right, I use the sign "$" because I ran out of options and need this code to compile. I know this is now what they asked.
I did not really understand this if (/\d/.test(allArticleTitles[index]))but I should have use the condition below.

        if (loopOnElement >="0"  or  loopOnElement <="9") then push

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