Skip to content

Juan Diego Sanchez Perez #3784

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
New iterations completed
  • Loading branch information
JDiegoSP committed May 12, 2023
commit 43ff1f8a61b5e1f2d13d49876f0c406c576af935
14 changes: 10 additions & 4 deletions src/functions-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ function maxOfTwoNumbers(arg1, arg2) {
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];

function findLongestWord(wordsArray) {

if (wordsArray.length === 0) return null;

let longestWord = [];
wordsArray.forEach(function(word) {
if(word.length > longestWord.length) {
longestWord = word;
}
}
});
return longestWord;
}
Expand All @@ -28,7 +31,7 @@ function findLongestWord(wordsArray) {
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];

function sumNumbers(sum) {
sumArray = 0;
let sumArray = 0;
sum.forEach(function(number){
sumArray += number;
});
Expand All @@ -46,8 +49,11 @@ function sum() {}
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];

function averageNumbers(avg) {
avgArray = 0;
avg.forEach(function(number){

if (avg.length === 0) return null;

let avgArray = 0;
avg.forEach(function(number){
avgArray += number;
});
return avgArray / avg.length;
Expand Down