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

BCN - Eva Pérez#551

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
evukipm wants to merge2 commits intoironhack-labs:masterfromevukipm:master
Closed
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
34 changes: 33 additions & 1 deletionstarter-code/src/functions-and-arrays.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
// Find the maximum
function maxOfTwoNumbers(num1, num2){
return Math.max(num1, num2);
}

// Finding Longest Word
var words = [
Expand All@@ -11,9 +14,26 @@ var words = [
'crackpot'
];

// Calculating a Sum
function findLongestWord(words) {
var longWord = words.sort(function (a, b) {
return b.length - a.length;
});
return longWord[0];
};

// Calculating a Sum
var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
var sum = 0;
function sumArray(numbers){
for(var i = 0; i < numbers.length; i++){
sum += numbers[i]
return sum;
};
};


// Log the sum
console.log(sum);

// Calculate the Average

Expand All@@ -33,6 +53,18 @@ var wordsArr = [
'palace'
];

/*function averageWordLenght(wordsArr){
wordsArr.forEach(word){
console.log(word.lenght);
};
};*/
function averageWordLenght(wordsArr){
for(var i =0; i < wordsArr.lenght; i++){
return wordsArr[i].lenght;
}
};


// Unique Arrays
var wordsUnique = [
'crab',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp