-
Notifications
You must be signed in to change notification settings - Fork 5.8k
finish excercise #3
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,72 @@ | ||
| //By Ryan Jones and Darek Glowinski | ||
|
|
||
| // Names and Input | ||
|
|
||
|
|
||
| var driver1 = "John"; | ||
| var hacker2 = prompt(); | ||
|
|
||
| console.log("Driver's name is "+driver1); | ||
| console.log("Navigator name is "+hacker2); | ||
|
|
||
| if(driver1.length > hacker2.length) { | ||
| console.log("Driver has a longer name with "+ driver1.length + " characters"); | ||
| } else if( driver1.length < hacker2.length) { | ||
| console.log("Navigator has a longer name with "+ hacker2.length + " characters"); | ||
| } else { | ||
| console.log("Both names are equal length of "+hacker2.length+ " characters") | ||
| } | ||
|
|
||
| var upperName = ""; | ||
| for(var i=0; i<driver1.length; i++) { | ||
| upperName += driver1[i].toUpperCase() + " "; | ||
| } | ||
| console.log(upperName); | ||
|
|
||
| var backWards = reverseString(hacker2); | ||
| console.log(backWards); | ||
|
|
||
|
|
||
|
|
||
| //Conditionals | ||
| var palindrome = prompt("Type new string"); | ||
|
|
||
| palindrome = palindrome.replace(/[\s\,]/g, ''); | ||
|
|
||
|
|
||
| var checkPal = reverseString(palindrome); | ||
|
|
||
| if (palindrome === checkPal){ | ||
| console.log("It is a palindrome"); | ||
| } else { | ||
| console.log("It is not a palindrome"); | ||
| } | ||
|
|
||
|
|
||
| // Lorem ipsum generator | ||
| var string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac bibendum elit, et blandit erat. Nam vitae quam vel dolor lacinia vestibulum a ut ipsum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur luctus ultricies mi a tempus. Duis ut ipsum suscipit, tincidunt eros vel, sollicitudin dui. Praesent porttitor neque ornare arcu pellentesque, eget tincidunt dolor tincidunt. Interdum et malesuada fames ac ante ipsum primis in faucibus. Curabitur a mollis urna.\ | ||
| \ | ||
| Aenean sollicitudin, orci sit amet interdum rhoncus, ligula augue pharetra lacus, sed consectetur lectus lacus vitae mi. Mauris a quam vehicula, elementum risus eu, vehicula sem. Donec ut ipsum dictum, viverra sapien nec, ultrices nulla. Phasellus lorem massa, blandit at hendrerit nec, posuere quis sem. Nam convallis nisl id ex semper varius. Praesent suscipit faucibus nisl vel commodo. Quisque lacinia, nisi quis luctus tincidunt, lacus nibh dictum orci, ac auctor ligula tortor in ipsum. Proin volutpat aliquet neque eget pretium. In volutpat, libero et tincidunt ullamcorper, mauris tellus lobortis metus, vitae convallis ipsum velit eu nisl.\ | ||
| \ | ||
| Maecenas vitae velit pretium, blandit odio a, aliquam nunc. Aliquam pretium, turpis ac finibus malesuada, eros massa tincidunt diam, non efficitur sem dui ut quam. Nunc at tincidunt magna, non tempus diam. Nullam accumsan suscipit ipsum, in dignissim nibh bibendum vel. Nulla viverra sodales neque, vitae fermentum nisi. Etiam lobortis pretium magna, vitae porta metus condimentum nec. Sed hendrerit venenatis ornare. Donec commodo vulputate nisi, in pulvinar felis lobortis dignissim. Etiam ac sodales mi, vel mollis turpis. Proin hendrerit odio non purus porttitor vestibulum. Duis accumsan quam ut urna viverra, a ultrices turpis consequat. Fusce pharetra sagittis turpis ut vestibulum. Aliquam in ligula laoreet nisi commodo venenatis. Sed et pellentesque eros, vitae sollicitudin mauris. Sed et ultricies nibh. Nunc auctor ante ac vestibulum egestas."; | ||
|
|
||
|
|
||
| var words = string.split(' '); | ||
| var split = words.length; | ||
| console.log("There are " + split + "words"); | ||
|
|
||
| var etCount = 0; | ||
| for(var i = 0; i<words.length; i++ ) { | ||
| if(words[i] === "et") { | ||
| etCount++; | ||
| } | ||
| } | ||
|
|
||
| console.log("Et appears "+etCount+" times"); | ||
|
|
||
| function reverseString(string) { | ||
| var result = ""; | ||
| for (var i = string.length - 1; i >= 0; i--){ | ||
| result += string[i]; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
#checked-well done