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

Appearance settings

MIA-Jeyson-JS_functions_array #320

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

jmxxii
Copy link

@jmxxii jmxxii commented Apr 3, 2018

No description provided.

@@ -11,15 +21,56 @@ var words = [
'crackpot'
];

function findLongestWord(array){
var longestWord;
var l = 0;

Choose a reason for hiding this comment

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

Bad choice choosing "l" as a variable. Usually, the only single letter variable people use is "i" , for loop counting. Other than that, It is not recommended to use single letter variables since they are not descriptive. Also "l" looks like the number 1 , which can cause confusion when quickly scanning the code.

Here is another solution to the same problem, even though yours works....

function findLongestWord(wordsArr) {
  var longest = wordsArr[0];
  var candidate;

  for (var i = 1; i < wordsArr.length; i++) {
    candidate = wordsArr[i];

    if (candidate.length > longest.length) {
      longest = candidate;
    }
  }
  return longest;
}

var longest = findLongestWord(words);
console.log(longest);


function sumArray(numbers){
var sum = 0;
for (var s = 0; s < numbers.length; s++){

Choose a reason for hiding this comment

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

Bad choice using "s" for the variable name. Why not just use "i" again ?

@ianizaguirre
Copy link

Try to apply this feedback on your next project.
If you have any questions on my feedback, just send me a message on Slack.
Aside from that, good job and keep up the good work! 😁

Kind Regards,
Ian Izaguirre | Ironhack TA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.