- Notifications
You must be signed in to change notification settings - Fork6.7k
mia-jens-functions and arrays#317
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
@@ -11,10 +19,27 @@ var words = [ | |||
'crackpot' | |||
]; | |||
function findLongestWord(wordsArray){ |
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.
Nope. You are not supposed to hardcode this find longest word function with something like "foo"?
This function was supposed to find the longest word from a list.
Here is the solution to this part, so you can compare the steps needed:
functionfindLongestWord(wordsArr){varlongest=wordsArr[0];varcandidate;for(vari=1;i<wordsArr.length;i++){candidate=wordsArr[i];if(candidate.length>longest.length){longest=candidate;}}returnlongest;}varlongest=findLongestWord(words);console.log(longest);
// Calculating a Sum | ||
var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; | ||
function sumArray(){ |
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.
Empty Function? You never completed this step. Here is the solution for this step, so you can check it out and make sense of how it works:
// Calculating a SumfunctionsumArray(array){varsum=0;for(varx=0;x<array.length;x++){sum+=array[x];}returnsum;}varnumbers=[6,12,1,18,13,16,2,1,8,10];vartotal=sumArray(numbers);console.log(total);
ianizaguirre commentedApr 11, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
You only completed about 20% of this assignment. If you want help understanding how to solve these problems, Slack me, and we can work on them together. Try to apply this feedback on your next project. Kind Regards, |
No description provided.