Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BCN - Linda & Santiago#215

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

Closed

Conversation

santironhacker
Copy link

Copy link
Contributor

@tawebbcntawebbcn 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, continue like that! 👍

@@ -11,6 +21,22 @@ var words = [
'crackpot'
];

function findLongestWord (box){
var longest = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

This function will fail returning undefined when the array is empty. You can solve this checking if the array is empty and returning undefined then. A better way is asign to your comparator (longest) the first array's element. If the array is empty, longest will be 'undefined' and the function will return 'undefined'. Using an internal element for comparision solve some tricky problems (e.g. finding a minimum).

function findLongestWord(box) {  var longest = box[0];  for (var i = 1; i < box.length; i++) {    if (box[i].length > longest.length) {      longest = box[i];    }  }  return longest;}

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tawebbcntawebbcntawebbcn left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@santironhacker@tawebbcn

[8]ページ先頭

©2009-2025 Movatter.jp