-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[SAO FT6 - PP - W1D3] Giulia & Barbosa #584
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
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,121 @@ | ||
| // Iteration 1: Names and Input | ||
|
|
||
| const hacker1 = 'Reginaldo'; | ||
| const hacker2 = 'Giulia'; | ||
| 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's 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 { | ||
| console.log(`Wow, you both have equally long names, ${hacker2.length} characters!`); | ||
| } | ||
|
|
||
| // Iteration 3: Loops | ||
| // Iteration 3: Loops | ||
|
|
||
| let outPutDrivers = ''; | ||
| for (let i = 0; i < hacker1.length; i += 1) { | ||
| outPutDrivers += `${hacker1[i].toUpperCase()} `; | ||
| } | ||
| let nameWithSpaces = outPutDrivers.slice(0, outPutDrivers.length - 1); | ||
| console.log(nameWithSpaces); | ||
|
|
||
| let outPutNavigator = ''; | ||
| for (let i = (hacker2.length - 1); i >= 0; i -= 1) { | ||
| outPutNavigator += hacker2[i]; | ||
| } | ||
| console.log(outPutNavigator); | ||
|
|
||
| // Bonus 3.3 | ||
|
|
||
| if (hacker1.localeCompare(hacker2) === -1) { | ||
| console.log('The driver\'s name goes first.'); | ||
| } else if (hacker1.localeCompare(hacker2) === 1) { | ||
| console.log('Yo, the navigator goes first definitely.'); | ||
| } else { | ||
| console.log('What?! You both have the same name?'); | ||
| } | ||
|
|
||
| // BONUS 01 | ||
|
|
||
| let lorem = 'Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste doloremque aliquid animi molestiae! Reiciendis amet similique ad assumenda voluptatibus iusto possimus iure delectus doloribus, nisi blanditiis, rem harum vel illum.\n Culpa voluptatibus harum iure nisi! Aliquam porro sunt illum, dolorum unde, tempora corporis hic accusamus minus iure saepe, voluptate voluptates consectetur libero magni delectus. Quisquam optio provident vitae nihil exercitationem.\n Tempora blanditiis facilis officia ratione, nam cupiditate ut placeat voluptate fugiat ad magnam aut expedita, adipisci aspernatur nesciunt inventore cum officiis pariatur omnis obcaecati libero delectus nostrum. Totam, ut soluta! et' | ||
|
|
||
| let indices = []; | ||
| let elemento = ' '; | ||
| let idx = lorem.indexOf(elemento); | ||
| while (idx != -1) { | ||
| indices.push(idx); | ||
| idx = lorem.indexOf(elemento, idx + 1); | ||
| } | ||
|
|
||
| console.log(`The number of words is ${indices.length + 1}`); | ||
|
|
||
| function numOfWords (elemento, whereIsTheWord) { | ||
| idx = lorem.indexOf(elemento); | ||
| indices = []; | ||
| while (idx != -1) { | ||
| indices.push(idx); | ||
| idx = lorem.indexOf(elemento, idx + 1); | ||
| } | ||
| console.log(`The number of 'et' in the ${whereIsTheWord} words is ${indices.length}`); | ||
| } | ||
|
|
||
| numOfWords ('Et ', 'start'); | ||
| numOfWords (' et ', 'middle'); | ||
| numOfWords (' et', 'end'); | ||
|
|
||
| // Bonus 2: | ||
|
|
||
| let phraseToCheck = 'A man, a plan, a canal, Panam'; | ||
| let phraseTemp = ''; | ||
| let phraseNormal = ''; | ||
| let phraseReverse = ''; | ||
|
|
||
| phraseTemp = phraseToCheck.toLowerCase(); | ||
| console.log(phraseTemp); | ||
|
|
||
| for (let i = 0; i < phraseTemp.length; i += 1) { | ||
| switch (phraseTemp[i]) { | ||
| case ' ': | ||
| case '!': | ||
| case ',': | ||
| case '.': | ||
| case '?': | ||
| case "'": | ||
| case '"': | ||
| case ':': | ||
| case '(': | ||
| case ')': | ||
| case ';': | ||
| break; | ||
| default: | ||
| phraseNormal += phraseTemp[i]; | ||
| } | ||
| } | ||
|
|
||
| console.log(phraseNormal); | ||
|
|
||
| for (let i = phraseNormal.length - 1; i >= 0; i -= 1) { | ||
| phraseReverse += phraseNormal[i]; | ||
| } | ||
|
|
||
| console.log(phraseReverse); | ||
|
|
||
| if (phraseNormal === phraseReverse) { | ||
| console.log('Yayyyy! It alive... It is indeed a palindrome!'); | ||
| } else { | ||
| console.log('Buuuuuu! Shit phraseeee!!!'); | ||
| } | ||
|
Comment on lines
+108
to
+112
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. Ótimas mensagens de console.log!! |
||
|
|
||
| // "A man, a plan, a canal, Panama!" | ||
| // "Amor, Roma" | ||
| // "race car" | ||
| // "stack cats" | ||
| // "step on no pets" | ||
| // "taco cat" | ||
| // "put it up" | ||
| // "Was it a car or a cat I saw?" and "No 'x' in Nixon". | ||
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.
Para substituir essa linha, procure um método chamado "trim()"