-
Notifications
You must be signed in to change notification settings - Fork 5.9k
PAR Jana & Thierry #148
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
PAR Jana & Thierry #148
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 |
|---|---|---|
|
|
@@ -5,3 +5,65 @@ | |
|
|
||
|
|
||
| // Lorem ipsum generator | ||
|
|
||
| var hacker1= "Jana"; | ||
| var hacker2= prompt("what is the navigator's name?"); | ||
| hacker2 = hacker2.toLowerCase(); | ||
| console.log("The driver's name is " + hacker1); | ||
| console.log("The navigator's name is " + hacker2); | ||
|
|
||
| if (hacker1.length > hacker2.length) { | ||
| console.log("The Driver has the longest name, it has " + hacker1.length + " characters"); | ||
| } | ||
| else if (hacker1.length < hacker2.length) { | ||
| console.log("Yo, navigator got the longest name, it has " + hacker2.length + " characters"); | ||
| } | ||
| else if (hacker1.length === hacker2.length) { | ||
| console.log("wow, you both got equally long names, " + hacker1.length + " characters"); | ||
| } | ||
|
|
||
| var str=""; | ||
| for (var i = 0; i < hacker1.length; i++) { | ||
| console.log(hacker1[i].toUpperCase()); | ||
| str += hacker1[i].toUpperCase() + " "; | ||
| } | ||
| console.log(str); | ||
|
|
||
| console.log(hacker2.split('').reverse().join('')); | ||
|
|
||
| if(hacker1.toLowerCase().split('').sort() < hacker2.split('').sort()){ | ||
| console.log("driver's name goes first"); | ||
| } | ||
| else if(hacker1.toLowerCase().split('').sort() > hacker2.split('').sort()){ | ||
| console.log("Yo, the navigator goes first definitely"); | ||
| } | ||
| else { | ||
| console.log('What?! You both got the same name?'); | ||
| } | ||
|
|
||
| var palindrome = prompt("is this word a palindrome"); | ||
| // console.log(palindrome.split('')); | ||
| // console.log(palindrome.split('').reverse()); | ||
| // if (palindrome.split('') === palindrome.split('').reverse()) { | ||
| // console.log("this is a palindrome!"); | ||
| // } | ||
| // else { | ||
| // console.log("this is NOT a palindrome!"); | ||
| // } | ||
| var myvar = ""; | ||
| for (var i = palindrome.length - 1; i >= 0 ;i--){ | ||
| console.log(palindrome[i]); | ||
| myvar += palindrome[i]; | ||
| } | ||
|
|
||
| if (myvar===palindrome) { | ||
|
|
||
| console.log("this IS a palindrome"); | ||
| } | ||
| console.log(palindrome); | ||
| console.log(myvar); | ||
|
|
||
| var paragraphs = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu pulvinar ex, sit amet fermentum magna. Mauris facilisis, risus eget rutrum porttitor, quam ipsum rutrum nulla, vitae ultricies odio elit a tellus. Nunc in ex id nunc lacinia pellentesque. Praesent varius ultricies dapibus. Sed eu ante dignissim, vehicula tellus eget, blandit lectus. Vestibulum id libero pulvinar, ullamcorper est ut, tempus metus. Proin finibus nulla pulvinar nisi efficitur, id vulputate velit imperdiet. Quisque a magna suscipit, ornare nulla a, pellentesque nunc. Maecenas efficitur, odio nec laoreet elementum, leo est venenatis dui, sit amet convallis leo nisi vel nulla. Praesent eget lorem id orci consequat aliquet aliquet in ipsum. Sed egestas, erat eget rhoncus ullamcorper, ligula felis maximus nunc, id venenatis nulla nisi pharetra sem. Donec vehicula euismod tellus, quis faucibus erat vestibulum id. Donec vitae elit vel orci facilisis imperdiet aliquet ac urna. Nam orci ligula, euismod eu erat id, tincidunt imperdiet lacus. Praesent dolor quam, aliquet vel urna vitae, varius feugiat erat. Cras rutrum mollis laoreet. Vestibulum euismod purus metus, non lacinia turpis tristique eget. Fusce efficitur sapien eu sagittis luctus. Proin eros ligula, pulvinar eu varius nec, iaculis vel felis. Nulla gravida aliquet enim, at faucibus diam tristique nec. Proin mauris massa, luctus bibendum faucibus ac, porttitor non elit. Nulla dignissim nunc nec egestas luctus. Donec varius nibh quam, vitae vulputate magna mollis eget. Morbi consequat leo sit amet mi semper, quis sollicitudin tellus viverra. Aenean justo tortor, vestibulum quis rutrum egestas, volutpat at felis. Vivamus hendrerit mollis tellus. Pellentesque sagittis, quam ac hendrerit dapibus, ipsum augue eleifend est, ut efficitur leo arcu ut velit. Ut pulvinar, neque sed dignissim venenatis, risus libero sollicitudin libero, et sollicitudin libero est sed orci. Donec hendrerit diam nec turpis aliquam, ac venenatis mauris laoreet." | ||
|
|
||
| console.log(paragraphs.split(' ').length); | ||
| console.log(paragraphs.indexOf('et')); | ||
|
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. The indexOf method allow you to catch the actual index (the position in an array) of a specific element, in your case it will output 24, because the first occurence of "et" is at the index 24 of the array. What you can try is to create an empty array, then iterate over "paragraphs" and add an if else statement that will push "et" whenever the loop encounters it, and then you just have to use the length method to know the actual number of element :) |
||
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.
It won't work like this, as you are sorting all the letters, per exemple in Jana, as there is two "a" it will be sorted before "arthur" (only one "a") but it shouldn't ;)
You only have to remove the .sort() method and you code will be good !