- Notifications
You must be signed in to change notification settings - Fork5.8k
Solved lab#3567
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
pablovqueiroz wants to merge2 commits intoironhack-labs:masterChoose a base branch frompablovqueiroz:master
base:master
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.
Uh oh!
There was an error while loading.Please reload this page.
Open
Solved lab#3567
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
93 changes: 92 additions & 1 deletionindex.js
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,98 @@ | ||
| // Iteration 1: Names and Input | ||
| const hacker1 = "Pablo"; | ||
| const hacker2 = "Luis"; | ||
| console.log(`The driver's name is ${hacker1}.`); | ||
| console.log(`The navigator's name is ${hacker2}.`); | ||
| // Iteration 2: Conditionals | ||
| function isLonger(hacker1, hacker2) { | ||
| const driver = hacker1.length; | ||
| const navigator = hacker2.length; | ||
| if (driver === navigator) { | ||
| return `Wow, you both have equally long names, ${driver} characters!.`; | ||
| } else if (driver > navigator) { | ||
| return `The driver has the longest name, it has ${driver} characters.`; | ||
| } else if (driver < navigator) { | ||
| return `It seems that the navigator has the longest name, it has ${navigator} characters.`; | ||
| } | ||
| } | ||
| console.log(isLonger(hacker1, hacker2)); | ||
| // Iteration 3: Loops | ||
| let resultDriver = ""; | ||
| const hacker1Spaced = hacker1.toUpperCase().split(""); | ||
| //console.log(hacker1Spaced) | ||
| for (let i = 0; i < hacker1Spaced.length; i++) { | ||
| resultDriver += `${hacker1Spaced[i]} `; | ||
| } | ||
| console.log(resultDriver.trim()); //.trim() foi mencionado na aula, mas não estudei ainda. melhor solução. | ||
| //------3.2------- | ||
| let hacker2Mirror = ""; | ||
| for (let i = hacker2.length - 1; i >= 0; i--) { | ||
| hacker2Mirror += hacker2[i]; | ||
| } | ||
| console.log(hacker2Mirror); | ||
| //------3.3------- | ||
| ///////////the way that i did. | ||
| // if (hacker1.toLocaleLowerCase() < hacker2.toLocaleLowerCase) { | ||
| // console.log(`The driver's name goes first.`); | ||
| // } else if (hacker1.toLocaleLowerCase() > hacker2.toLocaleLowerCase()) { | ||
| // console.log(`Yo, the navigator goes first, definitely.`); | ||
| // } else { | ||
| // console.log(`What?! You both have the same name?`); | ||
| // } | ||
| //////////the corection | ||
| const newLecicalName = hacker2.localeCompare(hacker1) | ||
| if (newLecicalName === -1) { | ||
| console.log(`Yo, the navigator goes first, definitely.`); | ||
| } else if (newLecicalName === 1) { | ||
| console.log(`The driver's name goes first.`); | ||
| } else if (newLecicalName === 0){ | ||
| console.log(`What?! You both have the same name?`); | ||
| } | ||
| /************BONUS 01*******************/ | ||
| const longText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean vel cursus mi, sit amet cursus purus. Ut ut dapibus magna. Aenean augue nibh, dignissim vel mi sed, sodales aliquam quam. Aenean ligula nunc, feugiat vel ipsum ac, gravida tincidunt massa. Aenean tempor dapibus metus. Quisque porttitor porta dolor nec consequat. Sed consectetur ut libero sit amet semper. Nunc placerat vestibulum posuere. Nullam ac aliquam augue, at rutrum est. Nunc at quam ut mauris vestibulum fermentum. Quisque hendrerit, augue ut dapibus molestie, urna sem faucibus erat, vitae placerat justo risus vitae ante. Phasellus posuere sapien nec sapien vulputate, in luctus nisl porta. Maecenas sed arcu aliquam, rutrum nibh in, eleifend mauris. Mauris ultrices sem lacus, ac dictum nibh luctus ac. Vestibulum nec erat egestas, maximus diam id, fermentum magna. Vestibulum pellentesque mauris vel libero malesuada pulvinar. Duis sed nunc orci. Nulla eu arcu consequat, elementum massa nec, bibendum nunc. Etiam in purus nunc. Nam ornare lacus ut est pellentesque, ac elementum purus maximus. Curabitur aliquam lectus ipsum, ut varius eros vulputate nec. Donec sed luctus tellus, nec suscipit felis. Sed nec nisi a eros aliquam ultrices. Cras maximus nec ex vitae volutpat. Integer ultricies condimentum malesuada. Donec ac commodo purus. Curabitur luctus tincidunt eleifend. Curabitur sodales justo vel hendrerit mollis. Sed nec molestie nibh, eu semper erat. Donec condimentum vitae risus id pharetra. Sed vitae dui dolor. Donec placerat purus id orci auctor, non malesuada ligula porta. Phasellus at enim eget metus vestibulum pretium id ut mi. Maecenas eget aliquam ex. Morbi laoreet laoreet fringilla. Fusce varius, erat sed tincidunt sollicitudin, eros ante feugiat sem, a rhoncus nisl nulla a purus. Cras purus sem, tempus a consequat quis, eleifend quis mauris. Quisque at interdum lacus et et et."; | ||
| ///////////////////////////////////////////////////////////////////// I added three "et"s to the end of the paragraph to ensure proper verification. | ||
| const longTextChars = longText.length; | ||
| console.log(longTextChars) | ||
| let count = 0; | ||
| for(let i = 0; i <longText.length; i++){ | ||
| const twoChars = longText[i] + longText[i + 1] + longText[i + 2] + longText[i + 3]; | ||
| if (twoChars.toLowerCase() === " et " || twoChars.toLowerCase() === " et.") { | ||
| count++ | ||
| } | ||
| } | ||
| console.log(count) | ||
| // /************BONUS 02*******************/2 | ||
| let resultPhrase = ''; | ||
| const phraseToCheck = "A man, a plan, a canal, Panama!"; | ||
| let phraseToCheckJoin = phraseToCheck.toUpperCase().replace(/[^\w\s]/g, '').split(' ').join(''); | ||
| console.log(phraseToCheckJoin) | ||
| for (let i = phraseToCheckJoin.length - 1; i >= 0; i--) { | ||
| resultPhrase += phraseToCheckJoin[i]; | ||
| } | ||
| //console.log(resultPhrase) | ||
| if (resultPhrase === phraseToCheckJoin){ | ||
| console.log(true) | ||
| } else { | ||
| console.log(false) | ||
| } | ||
| // code """.replace(/[^\w\s]/g, '')""" It was a result from Google; I need a better understanding. |
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.