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

MIA Alejandra Del Valle and Chu #160

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 2 commits 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
10 changes: 10 additions & 0 deletions 10 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ Define a function `maxOfTwoNumbers` that takes two numbers as arguments and retu
```javascript
function maxOfTwoNumbers(first, second){
// Your Code Here
function maxOfTwoNumbers(first, second){
if (first > second) {
console.log(first);
} else {
console.log(second);
}
}

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

var largest = maxOfTwoNumbers(2, 6);
Expand Down
42 changes: 35 additions & 7 deletions 42 starter-code/functions-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
// Find the maximum
function maxOfTwoNumbers (first, second) {

if (first > second) {
console.log(first);
} else {
console.log(second);
}
}

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

// Finding Longest Word
function findLongestWord (words) {

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

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

// Calculating a Sum
function sumArray (array) {

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

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

// Calculate the Average
function averageNumbers (array) {

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

var numbers = [2, 6, 9, 10, 7, 4, 1, 9];
Expand All @@ -43,7 +62,12 @@ console.log(average);

// Array of Strings
function averageWordLength (array) {

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

var words = [
Expand All @@ -63,7 +87,11 @@ console.log(averageLength);

// Unique Arrays
function uniquifyArray (array) {

for (var i = 0; i < array.length; i++){
if (array[i] === array[i+1]){
array.splice(i,1);
}
}
}

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