Skip to content
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 .DS_Store
Binary file not shown.
Binary file added starter-code/.DS_Store
Binary file not shown.
39 changes: 34 additions & 5 deletions starter-code/functions-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
// Find the maximum
function maxOfTwoNumbers (first, second) {

function maxOfTwoNumbers(first, second){
if (first > second) {
largest = first;

}
else if (second > first) {
largest = second;

}
else {
console.log("The numbers are the same");
}
return largest;
}

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

// Finding Longest Word
function findLongestWord (words) {

}

var words = [
"mystery",
"brother",
Expand All @@ -20,8 +29,28 @@ var words = [
"orchard",
"crackpot"
];

var numbers = [];
var newLargestWord = 0;

function findLongestWord(words){

for (i=0; i<words.length; i++) {
numbers[i] = words[i].length
console.log("test", numbers)

if (numbers[i] > newLargestWord) {
var newLargestWord = numbers[i];
console.log(newLargestWord)
}

}
}


var longest = findLongestWord(words);
console.log(longest);
// crocodile

// Calculating a Sum
function sumArray (array) {
Expand Down