- Notifications
You must be signed in to change notification settings - Fork6.7k
PAR Ghaith & Diane#409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| functionfindLongestWord(words){ | ||
| varmaxLengthWord=words[0].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.
You should assign an empty value to this variable, per exempl :
varmaxLengthWord=""
It's better, because words (your array) can be empty, so you won't be able to refer to the index 0 of the Array, if you use this, it will remove some error from jasmine :)
| functionfindLongestWord(words){ | ||
| varmaxLengthWord=words[0].length; | ||
| for(vari=0;i<words.length;i++){ | ||
| if(words[i].length>maxLengthWord){ |
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.
To stick to the expectation of the test, you should add an if that manage to return undifined if the array is empty
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 missing something in the if statement, as you are comparing the length of a word with a word (and not with the length of this word), it should be :
words[i].length>maxLengthWord.length
ta-web-paris commentedMay 29, 2018
As I told you you have to stick to requirement of the jasmine (typo, ect..), to remove some error that are still there, you have to deal with some special case (empty array per exemple). Otherwise your code is good ! 👍 If you have any question, let me know :) |
@GhaithHan