From 7fc224a7d05460ff549d8e77c9a5a7e30d83368e Mon Sep 17 00:00:00 2001 From: ventdlnord Date: Tue, 17 Oct 2017 16:57:18 +0200 Subject: [PATCH] exercise tuesday --- .DS_Store | Bin 0 -> 6148 bytes starter-code/functions-and-arrays.js | 59 +++++++++++++++++++++++---- starter-code/words.html | 22 ++++++++++ 3 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 .DS_Store create mode 100644 starter-code/words.html diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f6ef8a43895a7288ae061bc3ceb450b3251991d7 GIT binary patch literal 6148 zcmeHK%}T>S5T3176IAR$(BobN4^>(!Du@tkJ@g=m6+NhEVuA)@R+`kJwUXD+H}Fw> z0v|_be=3$Lcu`blVCI|Mo!KGZhW!BmR&DuZfC2zms1kEFnh!*dOC6A$>B%E9HOCfg z!U9}?UylZ&spB^?AlJ@@9bC6{sKLAS6Q^DzJRFt3#wzOEixTtz#vy?eTxg;V(9Xjt z2=F1OM}2vZU(NH{$)&0H=Bh%+g_%yLvRE$i zN_nMQ`>B{~K(jcV&aqn-eW@*1fGeR*M& zIozOQFw=-5C`_j!>QrW)7)+;QKR0oX!Azr02WB20%v5IPg~C*IoS&<3V2(zz!~ikS z&%lsw7UcQA`T6_5KZ#nz05R~d7-0EYqgKUFGH2_+$H}vnqn@Bjk#U*Ew-j{LQH-(j eD4s!8g8f`Nh>pQbBle)sML^L&h8Xx!23`SdiEu*z literal 0 HcmV?d00001 diff --git a/starter-code/functions-and-arrays.js b/starter-code/functions-and-arrays.js index 039bef297..ec8a2c0be 100644 --- a/starter-code/functions-and-arrays.js +++ b/starter-code/functions-and-arrays.js @@ -1,14 +1,34 @@ // Find the maximum function maxOfTwoNumbers (first, second) { - + if (first>second){ + console.log ("first"); + } + else if (second>first){ + console.log ("second"); + } + else { + console.log("the numbers are the same"); + } } var largest = maxOfTwoNumbers(2, 6); console.log(largest); // Finding Longest Word -function findLongestWord (words) { +function findLongestWord (words) { + var biggest=""; + for ( var ix=0; ix < words.length; ix++){ + if ( biggest.length < words[ix].length){ + biggest=words[ix]; + } + } + for ( var j=0; j +function findLongestWord (words) { + var LongestWord=""; + words.forEach(function(word){ + if(word.lenght>longestWord.lenght){ + longestWord = word; + } + }); + return longestWord; + } + + +var words = [ + "mystery", + "brother", + "aviator", + "crocodile", + "pearl", + "orchard", + "crackpot" +]; +