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

PTMEX-AnabelPerez #357

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
Changes from all commits
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
95 changes: 60 additions & 35 deletions 95 starter-code/src/functions-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,78 @@
// Find the maximum
function maxOfTwoNumbers (numero1, numero2){
if (numero1 > numero2)
return numero1;
else return numero2;
}// Find the maximum

// Finding Longest Word
var words = [
'mystery',
'brother',
'aviator',
'crocodile',
'pearl',
'orchard',
'crackpot'
];

// Calculating a Sum
var words = ['mystery','brother','aviator','crocodile','pearl','orchard','crackpot'];

function findLongestWord(words){
if (words.length==0) return;
var max = " ";
words.forEach (function(name){
if (name.length>max.length){
max = name;
};
});
return max
};

console.log (findLongestWord (words));



// Calculating a Sum
var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
function sumArray (numbers){
var suma = 0;
numbers.forEach (function(number){
suma = suma + number;
})
return suma;
}

// Calculate the Average

var numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];
var numbers= [2, 6, 9, 10, 7, 4, 1, 9];
function averageNumbers (numbers){
if (numbers.length==0) return;
var suma = 0;
numbers.forEach (function(number){
suma = suma + number;
})
return suma / numbers.length;
}


// Array of Strings
var wordsArr = [
'seat',
'correspond',
'linen',
'motif',
'hole',
'smell',
'smart',
'chaos',
'fuel',
'palace'
var wordsArr = ['seat','correspond','linen','motif','hole','smell','smart','chaos','fuel','palace'
];
function averageWordLength (wordsArr){
if (wordsArr.length==0) return;
var suma = 0;
wordsArr.forEach (function(word){
suma = suma + word.length;
})
return suma / wordsArr.length;
}

// Unique Arrays
var wordsUnique = [
'crab',
'poison',
'contagious',
'simple',
'bring',
'sharp',
'playground',
'poison',
'communion',
'simple',
'bring'
var wordsUnique = ['crab','poison','contagious','simple','bring','sharp','playground','poison','communion','simple',
'bring'
];

//function uniquifyArray (wordsUnique){
if (wordsUnique.indexOf("");
}

})
}




// Finding Elements
var wordsFind = [
'machine',
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.