Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mir592 wants to merge1 commit intoironhack-labs:masterfrommir592:master
Closed
Show file tree
Hide file tree
Changes fromall 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.DS_Store
View file
Open in desktop
Binary file not shown.
52 changes: 43 additions & 9 deletionsstarter-code/functions-and-arrays.js
View file
Open in desktop
Original file line numberDiff line numberDiff 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);

// Arrayof Strings
// Arrayaverage
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

[8]ページ先頭

©2009-2025 Movatter.jp