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

dev-mexpt2 Felipe Rocio Daniel #785

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
80 changes: 79 additions & 1 deletion 80 starter-code/src/functions-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// Find the maximum

function maxOfTwoNumbers(a,b){
if(a>b){
return a;
}else if(b>a) {
return b;
}else if(a === b){
return a;
} else{
return false
}
}
// Finding Longest Word
var words = [
'mystery',
Expand All @@ -11,14 +21,52 @@ var words = [
'crackpot'
];

function findLongestWord(words){
if(words.length == 0){
return undefined
}
var longestWord = ""
for (var i=0; i<words.length;i++){
if(words[i].length>longestWord.length){
longestWord = words[i]
}
}
return longestWord

}

// Calculating a Sum

var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];

function sumArray(){
if(numbers.length == 0){
return 0
}else if()
var count = 0;
for (var i=0; i<numbers.length; i++){
count= numbers[i] + count;
}
return count

}

// Calculate the Average

var numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];

function averageNumbers(numbers) {
var sum = 0
if (numbers.length === 0 ) {
return;
}
for (var i=0; i < numbers.length; i++) {
sum += numbers[i]
}
return sum/numbers.length;
}
console.log(averageNumbers(numbers));

// Array of Strings
var wordsArr = [
'seat',
Expand All @@ -33,6 +81,20 @@ var wordsArr = [
'palace'
];

function averageWordLength (words) {
if(wordsArr.length == 0){
return undefined
}
var count = 0;
for (var i=0; i<words.length; i++){
count = words[i].length + count;
}
console.log(count)
var average = count / words.length

return average
}

// Unique Arrays
var wordsUnique = [
'crab',
Expand Down Expand Up @@ -74,6 +136,22 @@ var wordsCount = [
'disobedience',
'matter'
];

var word = prompt("Cual palabra quieres?")
console.log(word)
ta-web-mex marked this conversation as resolved.
Show resolved Hide resolved

function howManyTimes(wordsCount){
if(wordsCount.length == 0){
return false
} else{
var count = 0;
for (var i = 0; i< wordsCount.length; i++){
if(wordsCount[i] == word)
count++
}
return count
}
}
// Bonus Quest

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