From 9c3e54de9d31c79bc9bd1d9ba86f1eb57ac8e509 Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Wed, 6 Nov 2019 20:34:59 +0100 Subject: [PATCH 1/8] include git.ignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9bf45ad40 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# General +.DS_Store +.vscode From bbd7fc739b837e77db099070ff49386ce46a1fb8 Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Thu, 7 Nov 2019 22:24:14 +0100 Subject: [PATCH 2/8] =?UTF-8?q?i=C2=B4m=20ready?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/index.js b/js/index.js index dd8ff0062..5c219227b 100644 --- a/js/index.js +++ b/js/index.js @@ -1,3 +1,4 @@ +console.log("I'm ready!"); // Iteration 1: Names and Input From 6ada498d78ca0c1780e00d03dbb76871d2174350 Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Thu, 7 Nov 2019 22:28:44 +0100 Subject: [PATCH 3/8] iteration1 --- js/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/index.js b/js/index.js index dd8ff0062..ec7084e21 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,10 @@ // Iteration 1: Names and Input +let hacker1 = "Rubén"; +let hacker2 = "Pedro"; + +console.log("The driver's name is", hacker1); +console.log("The driver's name is", hacker2); // Iteration 2: Conditionals From f6e3492ad9f301f7cb192d874ebbc154c2e6f502 Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Thu, 7 Nov 2019 22:46:24 +0100 Subject: [PATCH 4/8] iteration 2 end --- js/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/index.js b/js/index.js index e960f8592..48975296a 100644 --- a/js/index.js +++ b/js/index.js @@ -9,5 +9,15 @@ console.log("The driver's name is", hacker2); // Iteration 2: Conditionals +let hacker1Lenght = hacker1.length; +let hacker2Lenght = hacker2.length; + +if(hacker1Lenght > hacker2Lenght){ + console.log("The driver has the longest name, it has", hacker1Lenght, "characters."); + } else if(hacker1Lenght < hacker2Lenght){ + console.log("It seems that the navigator has the longest name, it has", hacker2Lenght, "characters."); + } else { + console.log("Wow, you both have equally long names,", hacker1Lenght, "characters."); +} // Iteration 3: Loops \ No newline at end of file From a1b0737b2f854dbcc7ec1ae6c0266cb653a5385c Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Fri, 8 Nov 2019 01:17:52 +0100 Subject: [PATCH 5/8] iteration3 end --- js/index.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 48975296a..9330fe204 100644 --- a/js/index.js +++ b/js/index.js @@ -20,4 +20,30 @@ if(hacker1Lenght > hacker2Lenght){ console.log("Wow, you both have equally long names,", hacker1Lenght, "characters."); } -// Iteration 3: Loops \ No newline at end of file +// Iteration 3: Loops + +console.log(hacker1.toUpperCase().split('').join(' ')); +let arrayHacker2 = hacker2.split(''); +let arrayNew = []; + +arrayHacker2.forEach(function(e){ + arrayNew.unshift(e); +}) + +console.log(arrayNew.join('')) + +let arrayOrden = []; + +arrayOrden.push(hacker1.toUpperCase(), hacker2.toUpperCase()); + +arrayOrden.sort(function (a,b) { + if (a > b) { + console.log("The driver's name goes first."); + return; + } else if (a < b) { + console.log('Yo, the navigator goes first definitely.') + return; + } + console.log('What?! You both have the same name?') + return; +}); \ No newline at end of file From dc663dec843ae7454c43c115c908fef79768fb05 Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Fri, 8 Nov 2019 01:59:15 +0100 Subject: [PATCH 6/8] bonus1 --- js/index.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 9330fe204..8707450c1 100644 --- a/js/index.js +++ b/js/index.js @@ -46,4 +46,28 @@ arrayOrden.sort(function (a,b) { } console.log('What?! You both have the same name?') return; -}); \ No newline at end of file +}); + +//Bonus 1 + +let lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin arcu eros, lobortis sed eros nec, auctor euismod massa. Cras in tincidunt enim. Integer at leo dui. Vestibulum ac lobortis turpis. Maecenas elementum malesuada leo, quis viverra urna efficitur ut. Nulla facilisi. Proin vel dui ligula. Phasellus non massa ut nibh rhoncus ultrices sit amet ut risus. Phasellus mollis nibh volutpat sapien vulputate, eu dapibus purus varius. Morbi suscipit accumsan diam a pulvinar. Nunc eu interdum mi, ac egestas erat. Mauris nunc est, imperdiet et quam auctor, posuere fermentum ipsum. Sed eget aliquet metus. Proin dapibus purus in massa interdum fermentum. Curabitur consequat consequat urna a porta. Curabitur aliquam velit eros, vel rhoncus erat viverra quis. Suspendisse nec nunc nisl. Duis velit purus, egestas quis hendrerit malesuada, mollis eu diam. Vestibulum nulla nibh, blandit ac tristique id, cursus a nunc. Quisque non quam in dui scelerisque volutpat ac sed ante. Etiam rutrum vehicula felis, ac pellentesque justo molestie quis. In tincidunt magna sed sem consequat, nec suscipit nulla tristique. Fusce justo sapien, feugiat nec velit vitae, convallis euismod tortor. Integer scelerisque ipsum vel sapien finibus, non vestibulum risus feugiat. Nunc egestas metus ac risus maximus, in porttitor justo gravida. Fusce eleifend, lacus in ullamcorper commodo, tortor odio posuere metus, vel maximus felis orci eu mauris. Nam sagittis odio lacinia nisi maximus efficitur. Vivamus luctus, dolor a vulputate dapibus, ex ipsum imperdiet arcu, eget dapibus lorem neque id arcu. In volutpat at ex nec elementum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris urna orci, pulvinar vel molestie in, placerat et nibh. Duis a eros eget dui tempus tincidunt at sed urna. In hac habitasse platea dictumst. Ut accumsan, risus a elementum placerat, sapien erat pharetra nibh, id imperdiet elit risus eget ante. Nullam quis ex sit amet ipsum blandit scelerisque non sed lectus. Donec scelerisque, lectus eu lacinia tristique, lorem dui suscipit arcu, quis hendrerit massa eros nec felis. Cras ac sollicitudin mi, non auctor tellus. Curabitur aliquam, libero vitae consectetur luctus, augue tellus ornare tellus, eget tempor metus velit vel lectus. Mauris eu auctor leo. Integer venenatis ante vitae aliquet vehicula. Donec ultrices nunc lectus, sit amet faucibus urna blandit sed. Aliquam erat volutpat." + +console.log('Numero de palabras:', lorem.split(' ').length); + +let arrayEt = []; +for(let i=0; i < lorem.length ; i++){ + var x = lorem.indexOf('et', i); + if(!arrayEt.includes(x) && x != -1){ + arrayEt.push(x); + } +} + +console.log(arrayEt.length); + +//Bonus 2 + +let examplePalindrome = "A man, a plan, a canal, Panama!"; + +examplePalindrome.forEach(function(e){ + console.log(e) +}) \ No newline at end of file From 59aa82f7104e25f07950a3ee379959f0e4a6029a Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Fri, 8 Nov 2019 18:03:22 +0100 Subject: [PATCH 7/8] bonus 2 --- js/index.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index 8707450c1..5a62857f6 100644 --- a/js/index.js +++ b/js/index.js @@ -68,6 +68,33 @@ console.log(arrayEt.length); let examplePalindrome = "A man, a plan, a canal, Panama!"; -examplePalindrome.forEach(function(e){ - console.log(e) -}) \ No newline at end of file +isPalindrome(examplePalindrome); + +function cleanString(string){ + let arrayElement = string.replace(/ /g, "").toUpperCase().split(''); + for(let i=0; i < arrayElement.length; i++){ + if(arrayElement[i] === "," || arrayElement[i] === "!" || arrayElement[i] === "'" || arrayElement[i] === '"' || arrayElement[i] === "?"){ + arrayElement.splice(i,1); + } + } + return arrayElement; +} + +function isPalindrome(string){ + + let arrayElement = cleanString(string); + + let counter = 0; + for(let i=0; i < arrayElement.length; i++){ + if(arrayElement[i] === arrayElement[arrayElement.length-1-i]){ + counter++; + } + } + + if(counter === arrayElement.length){ + console.log('The String is a Palindrome'); + } else{ + console.log('Not Palindrome'); + } + +} \ No newline at end of file From 243ddf0012e6ba4a94969bec4ec80d4339b2d3c2 Mon Sep 17 00:00:00 2001 From: Ruben Vaquero Date: Sun, 10 Nov 2019 18:42:17 +0100 Subject: [PATCH 8/8] incluir prompt user --- js/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 5a62857f6..f3ea66f3a 100644 --- a/js/index.js +++ b/js/index.js @@ -66,9 +66,9 @@ console.log(arrayEt.length); //Bonus 2 -let examplePalindrome = "A man, a plan, a canal, Panama!"; +let stringUser = prompt('Hello, Do you can to write a text?'); -isPalindrome(examplePalindrome); +isPalindrome(stringUser); function cleanString(string){ let arrayElement = string.replace(/ /g, "").toUpperCase().split('');