-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[webptmad0418]Octavio #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,91 @@ | ||
| var hacker1 = "Bob"; | ||
|
|
||
| console.log("The driver's name is " + hacker1); | ||
|
|
||
| var hacker2 = window.prompt("What's your name, Friendly neighbor?"); | ||
|
|
||
|
|
||
|
|
||
| console.log("The navigator's name is " + hacker2); | ||
|
|
||
| if (hacker1.length > hacker2.length) { | ||
|
|
||
| console.log("The Driver has the longest name, it has " + (hacker1.lenght) + "characters"); | ||
|
|
||
| } else if (hacker1.length < hacker2.length) { | ||
|
|
||
| console.log("Yo, navigator got the longest name, it has " + (hacker2.length) + " characters"); | ||
|
|
||
|
|
||
| } else { | ||
| console.log("wow, you both got equally long names, " + (hacker1.length) + " characters!!"); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| var hacker1UpperSeparated = hacker1.toUpperCase().split('').join(' '); | ||
|
|
||
|
|
||
| console.log(hacker1UpperSeparated); | ||
|
|
||
|
|
||
|
|
||
| var reverseHacker2 = hacker2.split('').reverse().join(''); | ||
|
|
||
| console.log(reverseHacker2); | ||
|
|
||
|
|
||
|
|
||
| if (hacker1>hacker2) { | ||
|
|
||
| console.log("The driver's name goes first"); | ||
|
|
||
| } else if (hacker2>hacker1) { | ||
| console.log("Yo, the navigator goes first definitely"); | ||
|
|
||
| } else { | ||
| console.log("what?! You both got the same name?"); | ||
| } | ||
|
|
||
|
|
||
| var isItPalindrome = prompt("Try to write a palindrome, brah").toLowerCase().replace(/\s/g, '').replace(/[',.'"?]/g, ""); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No me vale, te diría que no a un solo replace( ), con lo que dos no puede ser. Inténtalo sin usar expresiones regulares |
||
| var reverseIsItPalindrome = isItPalindrome.split('').reverse().join(''); | ||
|
|
||
|
|
||
| /*console.log(isItPalindrome); | ||
| console.log(reverseIsItPalindrome);*/ | ||
|
|
||
|
|
||
| //Punto 9// | ||
|
|
||
|
|
||
| if (isItPalindrome === reverseIsItPalindrome) { | ||
|
|
||
| console.log("It's a Palindrome!"); | ||
|
|
||
| } else { | ||
| console.log("Mmm, not a Palindrome") | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| //Punto 10// | ||
|
|
||
|
|
||
| var loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet, massa ac tristique rutrum, ex erat dictum libero, pretium euismod purus nisi eu odio. In finibus purus nunc, ut commodo est convallis sit amet. Aliquam id bibendum ipsum. Aliquam eu facilisis felis. Phasellus lacinia, felis nec rhoncus tincidunt, sapien magna imperdiet velit, eu placerat urna erat vel justo. Curabitur tempus ullamcorper risus, id convallis erat vulputate et. Aliquam sollicitudin lectus id felis euismod, ac laoreet mauris laoreet. Aenean pharetra mauris at arcu porta tempus. Nullam a consequat nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus semper at turpis ac congue. Proin facilisis placerat ante, eget pharetra lacus rutrum et. Integer eu commodo neque. Suspendisse vel volutpat quam. Pellentesque quis finibus nulla, ac aliquet dolor. Mauris id nibh turpis. Pellentesque posuere auctor ante ut suscipit. Phasellus condimentum risus purus, nec ornare neque ultricies porttitor.Aenean non dui nec sem condimentum condimentum. Morbi iaculis velit cursus euismod fermentum. Integer feugiat ex nec arcu ultricies, id pellentesque augue luctus. Pellentesque blandit, libero et pretium lacinia, urna nibh interdum quam, nec laoreet velit lorem vitae leo. Nulla semper, lectus interdum dapibus venenatis, neque nunc efficitur diam, ac blandit orci ipsum quis ipsum. Cras molestie eleifend pretium. Sed ultricies accumsan sapien eget tincidunt. Maecenas placerat ante et dignissim placerat. Proin finibus felis sed enim fermentum molestie." | ||
|
|
||
|
|
||
|
|
||
| console.log(loremIpsum.split(" ").length); | ||
|
|
||
| var count = loremIpsum.match(/\bet\b/g); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Como te comenté antes, inténtalo sin expresiones regulares. Javascript provée de métodos tremendamente útiles |
||
| count = count? count.length : 0; //checking if there are matches or not. | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esta evaluación es innecesaria. Si usas alguno de los métodos de javascript no te hace falta. |
||
| console.log(count); | ||
| // Names and Input | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ambas son correctas, pero dime, cómo lo harías sin utilizar split( ), join( ) y reverse( )?