-
Notifications
You must be signed in to change notification settings - Fork 5.8k
PAR Ghaith & Marie #151
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
PAR Ghaith & Marie #151
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,107 @@ | ||
// Names and Input | ||
var hacker1 = "Marie"; | ||
console.log("The dirver's name is " + hacker1); | ||
|
||
var hacker2 = "Ghaith"; | ||
console.log("The navigator's name is " + hacker2); | ||
|
||
//Conditionals | ||
var driverSize = hacker1.length; | ||
var navigatorSize = hacker2.length; | ||
|
||
if (driverSize > navigatorSize){ | ||
console.log("the navigator's name has the longest name, it has " + driverSize + " characters."); | ||
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. small typo error here : the driver's has the longest name, otherwise it will be the navigator everytime ;) |
||
} else if (navigatorSize > driverSize){ | ||
console.log("Yo, navigator has the longest name, it has " + navigatorSize + " characters."); | ||
} else { | ||
console.log("wow you both equally long names" + driverSize + " characters!!"); | ||
} | ||
|
||
|
||
var hacker1Maj = hacker1.toUpperCase(); | ||
|
||
var driverLetter = ""; | ||
for (var i=0; i<driverSize-1 ; i++){ | ||
driverLetter += hacker1Maj[i]; | ||
driverLetter += " "; | ||
} | ||
console.log(driverLetter + hacker1Maj[hacker1Maj.length-1]); | ||
|
||
var navigatorLetter = ""; | ||
for (var i = navigatorSize-1; i >= 0; i--){ | ||
navigatorLetter += hacker2[i]; | ||
} | ||
console.log(navigatorLetter); | ||
|
||
/* | ||
var drivUnicode = hacker1.charCodeAt(0); | ||
var navigUnicode = hacker2.charCodeAt(0); | ||
if (drivUnicode < navigUnicode){ | ||
console.log("The driver's name goes first"); | ||
} else if (navigUnicode < drivUnicode ){ | ||
console.log("Yo, the navigator goes first definitely !") | ||
} else { | ||
console.log("What?! You both got the same name?"); | ||
} */ | ||
|
||
var compare = hacker1.localeCompare(hacker2); | ||
if (compare > 0){ | ||
console.log("Yo, the navigator goes first definitely !") | ||
} else if (compare < 0) { | ||
console.log("The driver's name goes first"); | ||
} else { | ||
console.log("What?! You both got the same name?"); | ||
} | ||
|
||
//BONUS[ | ||
var input1 = prompt("Please enter a string"); | ||
var input = input1.toLowerCase(); | ||
var inputNew = ""; | ||
for (var i=0 ; i<= input.length-1 ; i++){ | ||
if (input[i] !== " " && input[i] !== "," && input[i] !== "?" && input[i] !== "!" && input[i] !== ":" && input[i] !== ";"){ | ||
inputNew += input[i]; | ||
} | ||
} | ||
|
||
var inputNewReverse =""; | ||
for (var i= inputNew.length-1; i>=0; i--){ | ||
inputNewReverse += inputNew[i]; | ||
} | ||
|
||
if (inputNew === inputNewReverse){ | ||
console.log("This is a palindrome"); | ||
} else { | ||
console.log("This is not a palindrome"); | ||
} | ||
|
||
|
||
//Ex10 | ||
var latinText = | ||
"Aenean vehicula enim a blandit consequat. Mauris ex neque, fringilla vel pretium et, scelerisque ut nunc. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent interdum commodo odio, quis consectetur enim interdum nec. Nam eget sagittis felis. Fusce pretium tincidunt lectus ac varius. Aenean pharetra eros ut diam facilisis, non iaculis leo gravida. In dui felis, semper vitae orci nec, fermentum molestie augue. Nunc non massa nisi. Etiam eget volutpat ipsum. Duis nisi sapien, pulvinar ac porttitor eget, interdum quis mi. Vivamus commodo eleifend pellentesque. Suspendisse nec ligula sapien. Nulla facilisi. Proin dapibus augue in sodales porta. Maecenas luctus non mauris ut tincidunt. Vestibulum eget mauris quis enim finibus fermentum.\ | ||
Morbi lectus sapien, gravida faucibus iaculis in, rhoncus ac dui. Curabitur ultrices ullamcorper felis vitae fermentum. Proin eget nunc sed orci ultrices sodales. In id sapien suscipit, ultricies nunc id, sodales risus. In eget elit ultricies, cursus dolor non, tincidunt turpis. Quisque malesuada libero velit, non porta orci rutrum aliquet. Curabitur luctus enim vitae aliquet vulputate. Aliquam eu dignissim ipsum. Nulla vel est vitae orci aliquet finibus eget at magna. Donec molestie mauris vitae augue laoreet, a viverra risus bibendum. Ut id ipsum efficitur, elementum enim in, fringilla orci. Quisque viverra mauris vel dolor blandit, vehicula aliquam velit volutpat. Vivamus sed mollis augue.\ | ||
Donec ornare felis et fringilla condimentum. Suspendisse potenti. In sed vestibulum orci. Ut vitae porta diam, pulvinar vehicula orci. Nullam auctor libero id justo tempor, at tristique nisl posuere. Duis dictum risus et fermentum malesuada. Praesent non nulla risus. In consectetur aliquet ex, ac blandit erat imperdiet vitae. Aenean congue posuere ligula, at feugiat tortor varius nec. Nullam id erat odio. Donec eget nisi dapibus, bibendum odio ut, aliquam nisl. In nec dui odio. Vivamus dictum nec nibh eget aliquam. Integer facilisis mauris orci, nec hendrerit lorem fringilla et. Quisque dignissim vestibulum leo, vel rutrum sem." | ||
|
||
var occ = 0; | ||
for (var i= 0; i<= latinText.length; i++){ | ||
if (latinText[i]=== " " || latinText[i]=== "\\" ){ | ||
occ++; | ||
} | ||
} | ||
|
||
//Because the last word doesn't have a space. | ||
occ+= 1; | ||
|
||
console.log("This text contains " + occ + " words.") | ||
|
||
var occEt =0; | ||
var latinText1 = latinText.toLowerCase(); | ||
for ( var i=0; i< latinText1.length; i++){ | ||
if (latinText1[i] === "e" && latinText1[i+1] === "t" && (latinText1[i+2] === " " || latinText1[i+2] === "." || latinText1[i+2] === ",") && latinText1[i-1] === " "){ | ||
occEt++; | ||
} | ||
} | ||
|
||
console.log("This text contains " + occEt + " 'et' words."); | ||
|
||
|
||
// Lorem ipsum generator |
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 can "generate" a dynamic name by asking the user :