forked from ironhack-labs/lab-javascript-basic-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 48
[LIS-WDFT-APR2023]elnaz #33
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
Open
elnazfe
wants to merge
2
commits into
MrAFerreira:main
Choose a base branch
from
elnazfe:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Iteration 1: Names and Input | ||
|
||
let hacker1 = "Elnaz"; | ||
let hacker2 = "Bruno"; | ||
console.log(`The driver's name is ${hacker1}`); | ||
console.log(`The navigator's name is ${hacker2}`) | ||
|
||
// Iteration 2: Conditionals | ||
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`) | ||
} | ||
|
||
// Iteration 3: Loops | ||
|
||
let hacker1Char = ""; | ||
for (let i = 0; i<hacker1.length; i++) { | ||
hacker1Char += hacker1[i]+ " "; | ||
} | ||
console.log(hacker1Char.toUpperCase()) | ||
|
||
let hacker2Rev = ""; | ||
for (let i = hacker2.length - 1; i >= 0; i--) { | ||
hacker2Rev += hacker2[i] | ||
} | ||
console.log(hacker2Rev); | ||
|
||
let answer = hacker1.localeCompare(hacker2) | ||
if ( answer === -1) { | ||
console.log(`${hacker1} goes first.`) | ||
} | ||
else if (answer === 1) { | ||
console.log(`Yo, ${hacker2} goes first definitely.`) | ||
} | ||
else { | ||
console.log("What?! You both have the same name?") | ||
} | ||
|
||
// Bonus 1 | ||
let longText =`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nunc tortor, scelerisque non diam sit amet, interdum porttitor arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris mollis sit amet tortor ac elementum. Suspendisse in orci sem. Quisque vitae ante sed neque eleifend mattis vel vel orci. Aliquam eleifend malesuada ex sed viverra. In venenatis nec magna at feugiat. Nam malesuada lorem eget arcu egestas convallis a eu nulla. Nam scelerisque diam ut pharetra venenatis. Maecenas placerat egestas dignissim. Proin at condimentum lacus. Nulla semper mi et nunc vehicula, quis dapibus elit aliquet. Integer ut elementum velit. Maecenas pulvinar condimentum auctor. | ||
|
||
Fusce elementum tincidunt lacus, at vulputate sapien accumsan eget. Phasellus tempor augue est, eu tincidunt ipsum tempor at. Curabitur enim urna, aliquam vel lacus id, tincidunt iaculis erat. Pellentesque blandit ex nisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis blandit pretium ligula sed gravida. Maecenas molestie maximus gravida. Proin eu molestie nunc. Sed euismod nunc erat, a pharetra lorem rhoncus at. Donec laoreet tortor ac dui fermentum, vitae sagittis sapien lacinia. Quisque mattis accumsan consectetur. Aliquam erat volutpat. | ||
|
||
Donec ac dictum felis. Fusce pretium pellentesque justo. Donec tristique, velit ac pharetra pretium, magna lacus auctor velit, id sagittis lorem leo a est. Cras tincidunt convallis ipsum, ut lacinia odio aliquam in. Aenean ac mi magna. Aliquam interdum justo vitae auctor iaculis. Etiam imperdiet turpis ligula, et feugiat lacus mattis vitae. Integer blandit leo quis sollicitudin scelerisque. Praesent pellentesque odio ac leo convallis luctus. Maecenas arcu orci, luctus ut eros sed, facilisis iaculis nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.` | ||
|
||
|
||
let wordCount = longText.split(" ").length; | ||
console.log(wordCount); | ||
|
||
|
||
/* | ||
let wordCount = 1 | ||
for (i = 0; i<longText.length; i++){ | ||
if(longText[i] === " "){ | ||
wordCount +=1 | ||
} | ||
} | ||
console.log(wordCount); | ||
|
||
let etCount; | ||
for (i = 0; i<longText.length; i++) { | ||
if(longText.char[i] === e && longText.char[i+1] === t) { | ||
etCount +=1 | ||
} | ||
} | ||
*/ | ||
|
||
let etCount = longText.split("et").length; | ||
console.log(etCount); |
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.
You should use the
.toUpperCase()
method inside the loop, otherwise you are not saving the string with the upper cased letters, you are just console logging it: