From f9c91e7bfb98e5c18b106e0c0b171f3c5a686907 Mon Sep 17 00:00:00 2001 From: afminguela Date: Tue, 17 Jun 2025 12:24:06 +0200 Subject: [PATCH 1/6] ejercicios 1 y 2 hechos --- index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/index.js b/index.js index 6b0fec3ad..85498f69b 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,34 @@ // Iteration 1: Names and Input +// 1.1 Create a variable hacker1 with the driver's name. +let hacker1= "jose Luis" +// 1.2 Print "The driver's name is XXXX". +console.log("The Driver´s name is "+ hacker1) +// 1.3 Create a variable hacker2 with the navigator's name. +let hacker2 = "garmin" +// 1.4 Print "The navigator's name is YYYY". + +console.log("The navigator's name is " + hacker2) // Iteration 2: Conditionals +// 2.1. Depending on which name [is longer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), print: +//
+// - `The driver has the longest name, it has XX characters.` or
+// - `It seems that the navigator has the longest name, it has XX characters.` or
+// - `Wow, you both have equally long names, XX characters!`. + +let fulano= hacker1.length; +let mengano= hacker2.length; + +if(fulano > mengano){ + console.log(`The driver has the longest name, it has ${fulano} characters.`) + +} else if(fulano > mengano) { + console.log(`It seems that the navigator has the longest name, it has ${mengano} characters.`) +} else { + console.log(`Wow, you both have equally long names, XX characters!`) +} + // Iteration 3: Loops From 5b2928b5159b8dd3e260fbb579830701287689c1 Mon Sep 17 00:00:00 2001 From: afminguela Date: Tue, 17 Jun 2025 13:50:51 +0200 Subject: [PATCH 2/6] ejercicios 3 hecho --- index.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/index.js b/index.js index 85498f69b..95dafdb30 100644 --- a/index.js +++ b/index.js @@ -32,3 +32,47 @@ if(fulano > mengano){ // Iteration 3: Loops +// 3.1 Print the characters of the driver's name, separated by space, and [in capital letters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase), i.e., `"J O H N"`. + +let patata = hacker1.toUpperCase().split('').join(" "); + +let str=""; +for ( i = 0; i < hacker1.length; i++) { + str += hacker1[i].toUpperCase()+ " " +} + + +console.log(patata); +console.log(str); + + + +// 3.2 Print all the characters of the navigator's name in reverse order, i.e., `"nhoJ"`. + + + +let str2=""; + +for (i = hacker2.length -1 ; i >= 0 ; i--){ + str2 += hacker2[i].toUpperCase(); +} + +console.log(str2) + + +// 3.3 Depending on the [lexicographic order](https://en.wikipedia.org/wiki/Lexicographical_order) of the strings, print:
+ +let tomate= hacker1.localeCompare(hacker2) + +if(tomate < 0){ + console.log(`The driver's name goes first.`) +} else if (tomate > 0){ + console.log(`Yo, the navigator goes first, definitely.`) +} else { + console.log(`What?! You both have the same name?`) +} + +// - `The driver's name goes first.`
+// - `Yo, the navigator goes first, definitely.`
+// - `What?! You both have the same name?` + From 43fd3c96615613c726e6668d98b3f07ac7c072cd Mon Sep 17 00:00:00 2001 From: afminguela Date: Tue, 17 Jun 2025 14:35:27 +0200 Subject: [PATCH 3/6] Bonus 1 --- index.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/index.js b/index.js index 95dafdb30..679cf0efc 100644 --- a/index.js +++ b/index.js @@ -76,3 +76,52 @@ if(tomate < 0){ // - `Yo, the navigator goes first, definitely.`
// - `What?! You both have the same name?` + +// Bonus 1: +// Go to the lorem ipsum generator website and: + +// Generate 3 paragraphs. Store the text in a new string variable named longText. +console.log('bonus1'); +let lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae elementum enim. Maecenas at arcu sagittis, hendrerit quam eget, finibus nulla. Duis scelerisque risus cursus libero ullamcorper, sed tristique magna aliquet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Duis vel velit a tellus ullamcorper hendrerit vel non orci. Suspendisse semper malesuada arcu id egestas. Pellentesque congue bibendum elit, et lacinia mi imperdiet in. Integer nisi massa, laoreet at neque et, posuere vehicula libero. Aliquam fringilla lorem ligula, nec sollicitudin magna congue sit amet. + +Donec vestibulum odio ex, in ullamcorper tellus accumsan eget. Donec orci justo, accumsan in vehicula a, ultricies ac nibh. Integer vehicula lorem eu odio ullamcorper venenatis. Vivamus sit amet tempus est, non semper libero. Cras semper tortor quis felis varius tincidunt. Donec suscipit sem vel justo venenatis semper vitae vitae lacus. Nam dignissim convallis sapien, ac euismod velit tincidunt eu. Morbi dapibus lacus nec magna imperdiet finibus. Maecenas dictum, dui pellentesque tristique iaculis, lorem nisi luctus purus, id vehicula ipsum urna vitae eros. Integer rutrum diam a condimentum rutrum. Donec vehicula, erat id eleifend porta, ex lectus eleifend nunc, at mollis eros urna vel est. Vestibulum viverra eros sed sapien luctus, et malesuada turpis accumsan. Fusce risus odio, imperdiet sed magna at, bibendum venenatis augue. Nulla molestie tortor ac porta cursus. Nunc sit amet laoreet mi, maximus fringilla ipsum. Vivamus non arcu at orci sodales consectetur. + +Cras cursus, nibh quis dictum pulvinar, metus sapien interdum lectus, vitae porta justo ante eu dui. Vestibulum in nunc vitae dolor varius ultricies. Nunc mi justo, hendrerit id dapibus sed, imperdiet venenatis nunc. Morbi tempor metus tortor, sollicitudin scelerisque turpis aliquam a. Etiam bibendum luctus nisl, egestas facilisis ex elementum sit amet. Proin in massa finibus, egestas erat in, malesuada tortor. Duis hendrerit mi tortor, ac eleifend lectus facilisis non. Vestibulum ullamcorper, metus quis fringilla dapibus, nisl lorem rhoncus felis, sed ornare diam velit non tortor. Integer nec sollicitudin turpis. Curabitur auctor lacus nunc, eget blandit sapien commodo rhoncus. Nam dapibus mi at diam pretium varius. Nullam quis purus nec est ullamcorper finibus. Aliquam vitae ante a turpis lobortis gravida. Praesent non pretium orci, non feugiat lorem. + +`; + + +// Make your program count the number of words in the string. +let count=0; +palabras = lorem.split(' '); +for (let i = 0; i < palabras.length; i++) { + count++ + } +console.log(count); + +// Make your program count the number of times the Latin word et appears. +let count2= 0; + +for (let i = 0; i Date: Tue, 17 Jun 2025 15:37:41 +0200 Subject: [PATCH 4/6] Bonus 2 --- index.js | 122 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/index.js b/index.js index 679cf0efc..027180bb6 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,13 @@ // Iteration 1: Names and Input // 1.1 Create a variable hacker1 with the driver's name. -let hacker1= "jose Luis" +let hacker1 = "jose Luis"; // 1.2 Print "The driver's name is XXXX". -console.log("The Driver´s name is "+ hacker1) +console.log("The Driver´s name is " + hacker1); // 1.3 Create a variable hacker2 with the navigator's name. -let hacker2 = "garmin" +let hacker2 = "garmin"; // 1.4 Print "The navigator's name is YYYY". -console.log("The navigator's name is " + hacker2) - +console.log("The navigator's name is " + hacker2); // Iteration 2: Conditionals @@ -18,70 +17,63 @@ console.log("The navigator's name is " + hacker2) // - `It seems that the navigator has the longest name, it has XX characters.` or
// - `Wow, you both have equally long names, XX characters!`. -let fulano= hacker1.length; -let mengano= hacker2.length; - -if(fulano > mengano){ - console.log(`The driver has the longest name, it has ${fulano} characters.`) +let fulano = hacker1.length; +let mengano = hacker2.length; -} else if(fulano > mengano) { - console.log(`It seems that the navigator has the longest name, it has ${mengano} characters.`) +if (fulano > mengano) { + console.log(`The driver has the longest name, it has ${fulano} characters.`); +} else if (fulano > mengano) { + console.log( + `It seems that the navigator has the longest name, it has ${mengano} characters.` + ); } else { - console.log(`Wow, you both have equally long names, XX characters!`) + console.log(`Wow, you both have equally long names, XX characters!`); } - // Iteration 3: Loops // 3.1 Print the characters of the driver's name, separated by space, and [in capital letters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase), i.e., `"J O H N"`. -let patata = hacker1.toUpperCase().split('').join(" "); +let patata = hacker1.toUpperCase().split("").join(" "); -let str=""; -for ( i = 0; i < hacker1.length; i++) { - str += hacker1[i].toUpperCase()+ " " +let str = ""; +for (i = 0; i < hacker1.length; i++) { + str += hacker1[i].toUpperCase() + " "; } - console.log(patata); console.log(str); - - // 3.2 Print all the characters of the navigator's name in reverse order, i.e., `"nhoJ"`. +let str2 = ""; - -let str2=""; - -for (i = hacker2.length -1 ; i >= 0 ; i--){ - str2 += hacker2[i].toUpperCase(); +for (i = hacker2.length - 1; i >= 0; i--) { + str2 += hacker2[i].toUpperCase(); } -console.log(str2) - +console.log(str2); // 3.3 Depending on the [lexicographic order](https://en.wikipedia.org/wiki/Lexicographical_order) of the strings, print:
-let tomate= hacker1.localeCompare(hacker2) +let tomate = hacker1.localeCompare(hacker2); -if(tomate < 0){ - console.log(`The driver's name goes first.`) -} else if (tomate > 0){ - console.log(`Yo, the navigator goes first, definitely.`) +if (tomate < 0) { + console.log(`The driver's name goes first.`); +} else if (tomate > 0) { + console.log(`Yo, the navigator goes first, definitely.`); } else { - console.log(`What?! You both have the same name?`) + console.log(`What?! You both have the same name?`); } // - `The driver's name goes first.`
// - `Yo, the navigator goes first, definitely.`
// - `What?! You both have the same name?` - // Bonus 1: // Go to the lorem ipsum generator website and: // Generate 3 paragraphs. Store the text in a new string variable named longText. -console.log('bonus1'); +console.log("bonus1"); let lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae elementum enim. Maecenas at arcu sagittis, hendrerit quam eget, finibus nulla. Duis scelerisque risus cursus libero ullamcorper, sed tristique magna aliquet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Duis vel velit a tellus ullamcorper hendrerit vel non orci. Suspendisse semper malesuada arcu id egestas. Pellentesque congue bibendum elit, et lacinia mi imperdiet in. Integer nisi massa, laoreet at neque et, posuere vehicula libero. Aliquam fringilla lorem ligula, nec sollicitudin magna congue sit amet. Donec vestibulum odio ex, in ullamcorper tellus accumsan eget. Donec orci justo, accumsan in vehicula a, ultricies ac nibh. Integer vehicula lorem eu odio ullamcorper venenatis. Vivamus sit amet tempus est, non semper libero. Cras semper tortor quis felis varius tincidunt. Donec suscipit sem vel justo venenatis semper vitae vitae lacus. Nam dignissim convallis sapien, ac euismod velit tincidunt eu. Morbi dapibus lacus nec magna imperdiet finibus. Maecenas dictum, dui pellentesque tristique iaculis, lorem nisi luctus purus, id vehicula ipsum urna vitae eros. Integer rutrum diam a condimentum rutrum. Donec vehicula, erat id eleifend porta, ex lectus eleifend nunc, at mollis eros urna vel est. Vestibulum viverra eros sed sapien luctus, et malesuada turpis accumsan. Fusce risus odio, imperdiet sed magna at, bibendum venenatis augue. Nulla molestie tortor ac porta cursus. Nunc sit amet laoreet mi, maximus fringilla ipsum. Vivamus non arcu at orci sodales consectetur. @@ -90,32 +82,62 @@ Cras cursus, nibh quis dictum pulvinar, metus sapien interdum lectus, vitae port `; - // Make your program count the number of words in the string. -let count=0; -palabras = lorem.split(' '); +let count = 0; +let palabras = lorem + .toLowerCase() + .replaceAll(",", "") + .replaceAll(".", "") + .split(" "); for (let i = 0; i < palabras.length; i++) { - count++ - } + count++; +} console.log(count); // Make your program count the number of times the Latin word et appears. -let count2= 0; +let count2 = 0; -for (let i = 0; i = 0; i--) { + reves += letras[i]; + } + console.log("me he dado la vuelta"); + + if (reves === sinNada) { + return "claro que si , guapi"; + } else { + return "pues va a ser que no"; + } +} + +console.log(hardPalindrome("Amor, Roma")); +console.log(hardPalindrome("Was it a car or a cat I saw?")); +console.log("estoy fuera de la funcion"); + // "A man, a plan, a canal, Panama!" // "Amor, Roma" // "race car" @@ -124,4 +146,4 @@ console.log(count2); // "taco cat" // "put it up" // "Was it a car or a cat I saw?" and "No 'x' in Nixon". -// IMPORTANT: If you use Google to help you to find a solution to this iteration, you might run into some advanced solutions that use string or array methods (such as join(), reverse(), etc.). However, we want you to apply your current knowledge and try to come up with a solution by just using the for loop and if-else statements with some break and continue. \ No newline at end of file +// IMPORTANT: If you use Google to help you to find a solution to this iteration, you might run into some advanced solutions that use string or array methods (such as join(), reverse(), etc.). However, we want you to apply your current knowledge and try to come up with a solution by just using the for loop and if-else statements with some break and continue. From b6d1f69625eef4516d647e1597fe0cbcc0afac55 Mon Sep 17 00:00:00 2001 From: afminguela Date: Tue, 17 Jun 2025 15:41:00 +0200 Subject: [PATCH 5/6] minor bug --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 027180bb6..9e077596d 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,7 @@ let mengano = hacker2.length; if (fulano > mengano) { console.log(`The driver has the longest name, it has ${fulano} characters.`); -} else if (fulano > mengano) { +} else if (fulano < mengano) { console.log( `It seems that the navigator has the longest name, it has ${mengano} characters.` ); From d03cf44fa8c7f2cdb2cd3732a2012dbec37d7915 Mon Sep 17 00:00:00 2001 From: afminguela Date: Wed, 18 Jun 2025 08:27:03 +0200 Subject: [PATCH 6/6] minor bug2 --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..a70911765 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": ["master"] +}