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

PP Paolo Miriam #109

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
Show file tree
Hide file tree
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
Binary file added BIN +6 KB .DS_Store
Binary file not shown.
52 changes: 43 additions & 9 deletions 52 starter-code/functions-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
// Find the maximum
function maxOfTwoNumbers (first, second) {

if(first<second){
return second;
}else if(second<first){
return first;
}else{
return ("they are equals")
}
}

var largest = maxOfTwoNumbers(2, 6);
console.log(largest);

// Finding Longest Word
function findLongestWord (words) {

}
var long;
var lgt = 0;
for(var i=0; i<words.length; i++){
if(words[i].length>lgt){
lgt = words[i].length;
long = words[i];
}
}
return long;
}

var words = [
"mystery",
Expand All @@ -25,7 +39,11 @@ console.log(longest);

// Calculating a Sum
function sumArray (array) {

var n = 0;
for(var i =0; i<array.length; i++){
n += array[i];
}
return n;
}

var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
Expand All @@ -34,15 +52,19 @@ console.log(total);

// Calculate the Average
function averageNumbers (array) {

}
return sumArray(array)/array.length;
}

var numbers = [2, 6, 9, 10, 7, 4, 1, 9];
var average = averageNumbers(numbers);
console.log(average);

// Array of Strings
// Array average
function averageWordLength (array) {
var n =0;
for(var i =0;i<array.length;i++){
n+= array[i].length
}return n/=array.length

}

Expand All @@ -62,9 +84,21 @@ var averageLength = averageWordLength(words);
console.log(averageLength);

// Unique Arrays
function uniquifyArray (array) {
function uniquifyArray (word) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Chicos!! Dadle duro!! Ese indexOf()!!

var n=0;
for(var i=0;i<word.length;i++);{
n = word[i];
for (var j =1;j<word.length;j++){
var x = word[i]
if(n===x){
word.splice(j);

}
}



}
}

var words = [
"crab",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.