-
Notifications
You must be signed in to change notification settings - Fork 5.9k
done #667
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
done #667
Changes from all commits
Commits
Show all changes
4 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,53 @@ | ||
| // Iteration 1: Names and Input | ||
| //it 1 | ||
| var hacker1 = 'Jason'; | ||
| console.log(`"The driver's name is ${hacker1}"`); | ||
|
|
||
| var hacker2 = 'Alexander'; | ||
| console.log(`"The navigator's name is ${hacker2}"`); | ||
|
|
||
| // Iteration 2: Conditionals | ||
| //it 2 | ||
| 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(`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`); | ||
| } else if (hacker1.length < hacker2.length) { | ||
| console.log(`Wow, you both have equally long names, ${hacker1.length} characters!`); | ||
| } | ||
|
|
||
| //it 3 | ||
| for (i = 0; i <= hacker1.length - 1; i++) { | ||
|
Contributor
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. you need to assign i to a variable, var i = 0 |
||
| console.log(hacker1[i].toUpperCase()); | ||
| } | ||
|
|
||
| // Iteration 3: Loops | ||
| for (var x = hacker2.length - 1; x >= 0; x--) { | ||
| console.log(hacker2[x]); | ||
| } | ||
|
|
||
| for (var i = 0; i < 1; i++){ | ||
| if (hacker1[i] < hacker2[i]) { | ||
| console.log("The driver's name goes first."); | ||
| } | ||
| else if (hacker1[i] > hacker2[i]) { | ||
| console.log("Yo, the navigator goes first definitely."); | ||
| } else { | ||
| console.log("What?! You both have the same name?"); | ||
| } | ||
| } | ||
|
|
||
| //bonus 1 | ||
| var loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In feugiat, orci et tempor dignissim, sem mauris vehicula lacus, non porta tellus purus ac diam. Ut molestie ultrices efficitur. Donec vitae tincidunt est. Nunc rutrum odio quis diam facilisis tempor. Donec maximus tristique quam sit amet vulputate. Fusce ut odio at ligula convallis semper eget eu tellus. Morbi sollicitudin congue elit, vitae faucibus est aliquet et. Maecenas ultricies mollis purus convallis porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam posuere ex elit, eu luctus mi varius ac. Donec vehicula sem orci, a sollicitudin sapien condimentum id. Aliquam cursus euismod odio, rutrum eleifend nibh. Maecenas vitae mauris scelerisque, tempor mi vitae, sollicitudin lectus. Fusce non elit turpis. Ut sapien justo, vestibulum mollis bibendum et, condimentum et dolor. Vestibulum gravida molestie mi porttitor fringilla. Suspendisse in quam in eros sagittis feugiat. Sed volutpat suscipit eleifend. Morbi ac tellus pharetra, accumsan tellus ac, tincidunt mauris. In pretium, orci vitae scelerisque maximus, velit est pharetra quam, a molestie odio mi nec lorem. Duis hendrerit urna dui, et egestas nunc venenatis eget. Maecenas placerat sodales tortor, sit amet facilisis sem ultrices sed. Morbi risus magna, dictum in velit sit amet, iaculis porttitor ipsum. Cras et magna et augue lobortis suscipit. Ut tristique, nunc sed semper condimentum, diam tellus dictum metus, a dictum sapien elit eget augue. Duis cursus mollis augue et mattis. Sed viverra tempus sodales. Aenean sem quam, varius quis facilisis eget, laoreet vel erat. Nullam nec congue dolor. Vivamus efficitur nunc orci, vitae aliquam leo congue posuere. Maecenas mattis diam nec nulla pharetra volutpat et in tellus. Proin elementum pretium libero quis commodo. Praesent porttitor pulvinar semper. Donec mollis, felis et dictum egestas, mauris ante ornare massa, vel aliquet neque purus sit amet diam. Nulla velit augue, eleifend eu consequat ut, ornare a nunc. Aenean ullamcorper nec dolor a convallis. Maecenas eu pulvinar sem. Curabitur nibh quam, sagittis vel rhoncus nec, suscipit convallis massa. Praesent molestie metus nec dolor vehicula tincidunt. Sed euismod, risus sit amet accumsan scelerisque, purus lectus pulvinar massa, bibendum lacinia dui nunc eu elit. Fusce eget imperdiet massa. Cras ut nibh ullamcorper massa tincidunt pulvinar at nec odio."; | ||
| var numberOfWords = 1; | ||
| for (var i = 0; i <= loremIpsum.length; i++) { | ||
| if (loremIpsum[i] == " ") { | ||
| numberOfWords++; | ||
| } | ||
| } | ||
| console.log(numberOfWords); | ||
|
|
||
| var count = 0; | ||
| for (var i = 0; i <= loremIpsum.length; i++){ | ||
| if (loremIpsum[i] == " " && loremIpsum[i+1] == "e" && loremIpsum[i+2] == "t" && loremIpsum[i+3] == " ") | ||
| count++; | ||
| } | ||
| console.log(count); | ||
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.
If you use the string interpolation, you don't need the quote inside, but you solve that later in the exercises, so good :)