From 1ef3e47225dcd022438f46dd35fcc163d385bb57 Mon Sep 17 00:00:00 2001 From: kainmaligno Date: Sun, 29 Apr 2018 11:21:04 -0500 Subject: [PATCH 1/3] lab-basic-algorithms --- starter-code/basic-algorithms.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 82f20d8ba..9c5b599cb 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -1,7 +1,37 @@ // Names and Input +var Hacker1 = prompt("The driver's name"); +var Hacker2 = prompt("The navigator's name is "); +console.log("the driver's name is " + Hacker1); + +console.log("The navigator's name is " + Hacker2); + +var Name1 = [Hacker1]; +var Name2 = [Hacker2]; + +var Hacker11 = Hacker1.split("").join(" ").toUpperCase(); +console.log(Hacker11); +var Hacker12 = Hacker2.split("").reverse().join(""); +console.log(Hacker12); //Conditionals +if(Hacker1.length > Hacker2.length){ + console.log("the driver has the longest name it has "+ Hacker1.length + " characters"); + +} else if (Hacker2.length> Hacker1.length){ + console.log("the navigator has the longest name it has "+ Hacker2.length + " characters"); + +} else if(Hacker1.length == Hacker2.length){ + console.log("Wow you goth equally long names it has "+ Hacker2.length+ " characters"); +} + +if(Name1>Name2){ + console.log("The driver's name goes first"); +}else if(Name2>Name1){ + console.log("Yo, the navigator goes first definitely"); +} else if(Name1 === Name2){ + console.log("What?! You both got the same name?"); +} // Lorem ipsum generator From 8c2bc7934bb9ab40f6a55984680b41538a39b4e5 Mon Sep 17 00:00:00 2001 From: kainmaligno Date: Sun, 29 Apr 2018 11:55:17 -0500 Subject: [PATCH 2/3] funcion para contar palabras dentro de lorem --- starter-code/basic-algorithms.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 9c5b599cb..aa6ecce9d 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -35,3 +35,9 @@ if(Name1>Name2){ } // Lorem ipsum generator + +function countWords(str){ + return str.split(" ").length; +} + + console.log(countWords(lorem)+" Words found at Lorem"); \ No newline at end of file From ef23de3496de3c1d7d72247f115b1b44d01abe79 Mon Sep 17 00:00:00 2001 From: kainmaligno Date: Sun, 29 Apr 2018 18:18:49 -0500 Subject: [PATCH 3/3] update at lab --- starter-code/basic-algorithms.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index aa6ecce9d..ab962ffae 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -40,4 +40,10 @@ function countWords(str){ return str.split(" ").length; } - console.log(countWords(lorem)+" Words found at Lorem"); \ No newline at end of file + console.log(countWords(lorem)+" Words found at Lorem"); + + + function countLatinWord(str1){ + return str1.match("et").length; + } + console.log(countLatinWord(lorem) + " Word 'et' found at lorem"); \ No newline at end of file