From 6869da327116c56c3ce240404e44475cab87e6a5 Mon Sep 17 00:00:00 2001 From: Edu Cortada Date: Tue, 5 Feb 2019 15:00:56 +0100 Subject: [PATCH 1/2] initial commit --- starter-code/basic-algorithms.js | 63 +++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 82f20d8ba..834b222ee 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -1,7 +1,68 @@ // Names and Input +let hacker1 = 'Matias'; +let hacker2 = ''; +hacker2 = prompt('Write the name of the navigator') + +console.log('The driver\'s name is ' + hacker1); + +console.log('The navigator\'s name is ' + hacker2) //Conditionals +if (hacker1.length > hacker2.length){ + console.log('The Driver has the longest name, it has ' + hacker1 + ' characters'); +} else if (hacker2.length > hacker1.length){ + console.log('Yo, navigator got the longest name, it has ' + hacker2 + ' characters') +} else { + console.log('wow, you both got equally long names, ' + hacker1.length + ' characters!!'); +} + +//Loops +let driverName = []; +let driverNameReverse; +for(let i = 0; i < hacker1.length; i++){ + driverName.push(hacker1[i]) +} + +driverNameReverse = driverName.reverse(); +driverName = driverName.join(' ').toUpperCase(); + + +console.log(driverName); + +if(hacker1.localeCompare(hacker2) === -1){ + console.log('The' + hacker1 + 'name goes first'); + } else if (hacker1.localeCompare(hacker2) === 1) { + console.log('Yo, the ' + hacker2 + ' goes first definitely') + } else{ + console.log('What?! You both got the same name?') +} + +// Bunus + +let palindrome = prompt('Wirte your messaje');; + +let arrayPalindrome = []; +let reversePalindrome; + +for(let i = 0; i < palindrome.length; i++){ + arrayPalindrome.push(palindrome[i]); +} +reversePalindrome = arrayPalindrome.reverse(); + +arrayPalindrome = arrayPalindrome.join(''); +arrayPalindrome = arrayPalindrome.replace(' ', ''); + +reversePalindrome = reversePalindrome.join(''); +reversePalindrome= reversePalindrome.replace(' ', ''); + +console.log(arrayPalindrome); +console.log(reversePalindrome); + -// Lorem ipsum generator +if(arrayPalindrome === reversePalindrome){ + console.log('is a palindrome!'); +} else { + console.log('isn\'t a palindrome'); +} \ No newline at end of file From b9d0884fe941580105153cf4f1ba434abf709526 Mon Sep 17 00:00:00 2001 From: Edu Cortada Date: Wed, 6 Feb 2019 10:01:15 +0100 Subject: [PATCH 2/2] Refactor bonus --- .gitignore | 1 + starter-code/basic-algorithms.js | 34 +++++++++++--------------------- starter-code/index.html | 14 +++++++++++++ 3 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 .gitignore create mode 100644 starter-code/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..496ee2ca6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 834b222ee..4c40580ba 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -41,28 +41,18 @@ if(hacker1.localeCompare(hacker2) === -1){ // Bunus -let palindrome = prompt('Wirte your messaje');; - -let arrayPalindrome = []; -let reversePalindrome; - -for(let i = 0; i < palindrome.length; i++){ - arrayPalindrome.push(palindrome[i]); -} -reversePalindrome = arrayPalindrome.reverse(); - -arrayPalindrome = arrayPalindrome.join(''); -arrayPalindrome = arrayPalindrome.replace(' ', ''); - -reversePalindrome = reversePalindrome.join(''); -reversePalindrome= reversePalindrome.replace(' ', ''); - -console.log(arrayPalindrome); +//Ingresa el mensaje en el prompt. +let palindrome = prompt('Wirte your messaje'); +//Limpia el mensaje en el prompt quitando los espacios y caracteres especiales. +let cleanPalindrome = palindrome.replace(/[^A-Z0-9]/ig, "").toLowerCase(); +//Escrible en revesa el palindromo para ser comparado. +let reversePalindrome = cleanPalindrome.split("").reverse().join("");; + +console.log(cleanPalindrome); console.log(reversePalindrome); - -if(arrayPalindrome === reversePalindrome){ - console.log('is a palindrome!'); -} else { - console.log('isn\'t a palindrome'); +if(cleanPalindrome === reversePalindrome){ + console.log('is a palindrome!'); + } else { + console.log('isn\'t a palindrome'); } \ No newline at end of file diff --git a/starter-code/index.html b/starter-code/index.html new file mode 100644 index 000000000..cb2293cf7 --- /dev/null +++ b/starter-code/index.html @@ -0,0 +1,14 @@ + + + + + Hello, world! + + + + + +

Hello World

+ + + \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy