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

BCN - Desiree Lucas Cristian #151

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 1 commit into from
Closed

Conversation

dvillool
Copy link

@dvillool dvillool commented Oct 17, 2017

@gominolas
@lacazeto

Copy link
Contributor

@tawebbcn tawebbcn left a comment

Choose a reason for hiding this comment

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

Key points:

  • If the function needs to return something, RETURN it.
  • DRY, Don't Repeat Yourself. Reuse your functions when possible.

That said, good job. Keep up the hard work. 👍

console.log ("second");
}
else {
console.log("the numbers are the same");
Copy link
Contributor

Choose a reason for hiding this comment

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

You are showing the result in the console instead of returning it. That way, the variable 'largest' in line 14 is going to be undefined (because you are not returning anything). Usually you want your functions to return something, that way you can use that value ahead.

biggest=words[ix];
}
}
for ( var j=0; j<words.lenght; j++){
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this second for. I understand you use it to display more than one result (if there is a tie for the longest word), but the problem again is that you MUST return the result instead of showing it in the console. In this case, if you want to display more than one word, you will need an array. If the function's signature is expecting an output of a value, returning an array could be a problem.


var totalSum=0;
array.forEach(function(number){
totalSum+=number;
Copy link
Contributor

Choose a reason for hiding this comment

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

Good job with the forEach. However, you have forgotten return something.

@@ -34,7 +58,11 @@ console.log(total);

// Calculate the Average
function averageNumbers (array) {

var totalSum=0;
array.forEach(function(number){
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have another function that sums all the values in an array? Then, maybe you can use it here instead of repeating code.

@@ -43,9 +71,14 @@ console.log(average);

// Array of Strings
function averageWordLength (array) {

var total=0;
array.forEach(function(number){
Copy link
Contributor

Choose a reason for hiding this comment

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

Good job. However, be careful with variable's names. Don't call it number if it is a word.


var biggest="";
for ( var ix=0; ix < words.length; ix++){
if ( biggest.length < words[ix].length){
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't want to find the biggest word, you want to check if that word is in the array.

@@ -0,0 +1,22 @@
<script>
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? Why are you including a script in another html file?

@tawebbcn tawebbcn closed this Oct 18, 2017
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.