Manchester NW5-Maziar Mansouri-JavaScript-Week3 - #123
Conversation
Danti8686
left a comment
There was a problem hiding this comment.
Hi Maziar,
I sow your work is amazing and you are hard worker and I looked to exercises/C-while-loop-with-array/exercise.js the function not give a result could you check it please and good luck
thank you I checked it was alrigth it returns "July 11th" |
| // TODO | ||
| let arr = []; | ||
| for (let i = 0; i < allArticleTitles.length; i++) { | ||
| if (/[0-9]/g.test(allArticleTitles[i])) { |
There was a problem hiding this comment.
I think the comment on the function was hinting that you use for of on the titles to iterate through and detect numbers, but a regex is definitely a more efficient solution 👍
| let randomNum = generateRandomNumber(); | ||
|
|
||
| if (randomNum > 50) return randomNum; | ||
| } while (1 < 52); |
There was a problem hiding this comment.
1 < 52 will always evaluate top true. While your solution works, I think the point of this exercise is to see if you can use the while clause to stop the loop once you've found a random number greater than 50. E.g.
function getRandomNumberGreaterThan50() {
let randomNum = 0;
do {
randomNum = generateRandomNumber();
} while (randomNum <= 50);
return randomNum
}There was a problem hiding this comment.
thank you Yes I did not pay attention I just check and when all tests passed I did the next one.
| */ | ||
| function titleWithFewestWords(allArticleTitles) { | ||
| // TODO | ||
| let str = allArticleTitles[0]; |
There was a problem hiding this comment.
Check the function comment again - the editor wants titles with the fewest words, not the fewest characters.
No description provided.