-
Notifications
You must be signed in to change notification settings - Fork 5.9k
PAR FTWD Ismael & Cecile Js Basics Algorithms LAB #401
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,57 @@ | ||
| // Names and Input | ||
| console.log("I'm Ready!"); | ||
| var hacker1 = "Ismaël"; | ||
| console.log("The driver's name is " + hacker1); | ||
|
|
||
| var hacker2 = prompt("What's the navigator's name?"); | ||
| console.log("The navigator's name is " + hacker2); | ||
|
|
||
| if (hacker1.length > hacker2.length) { | ||
| console.log( | ||
| hacker1 + "has the longest name, it has " + hacker1.length + " characters." | ||
| ); | ||
| } | ||
| if (hacker2.length > hacker1.length) { | ||
| console.log( | ||
| hacker2 + "has the longest name, it has " + hacker2.length + " characters." | ||
| ); | ||
| } | ||
|
|
||
| if (hacker2.length == hacker1.length) { | ||
| console.log( | ||
| "Wow, you both got equally long names, " + | ||
| hacker1.length + | ||
| " characters !!!" | ||
| ); | ||
| } | ||
|
|
||
| //Conditionals | ||
| var hacker1CapitalSpace = ""; | ||
|
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. une autre maniere |
||
| for (let i = 0; i < hacker1.length; i++) { | ||
| hacker1CapitalSpace += hacker1[i].toUpperCase() + " "; | ||
| } | ||
| console.log(hacker1CapitalSpace); | ||
|
|
||
| var hacker2Reverse = ""; | ||
|
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. Ca fonctionne tres bien. Juste une autre maniere |
||
| for (let i = hacker2.length - 1; i >= 0; i--) { | ||
| hacker2Reverse += hacker2[i]; | ||
| } | ||
| console.log(hacker2Reverse); | ||
|
|
||
| if (hacker1 < hacker2) { | ||
|
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. Attention ici, on veut verifier la valeur lexicographique. Chose que l'on utilise pas du tout dans notre vie de tout les jours mais ici c'etait la consigne et il y a un outil pour ca: |
||
| console.log("The driver's name goes first"); | ||
| } else if (hacker1 > hacker2) { | ||
| console.log("Yo, the navigator goes first definitely"); | ||
| } else { | ||
| console.log("What?! You both got the same name?"); | ||
| } | ||
|
|
||
| /* var hacker1 = hacker1.toUpperCase(); | ||
| var char1 = hacker1.split(""); | ||
| console.log(char1.join(" ")); | ||
|
|
||
| var char2 = hacker2.split (""); | ||
| var char2 = char2.reverse(); | ||
| console.log (char2.join (''));*/ | ||
|
|
||
| // Lorem ipsum generator | ||
|
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. CORRECTION DE LA SUITE: checkPal = () => { var test1 = isItAPal.toLowerCase().replace(/\s/g, '') // on retire les espaces avec .replace et une regex checkPal() var loremIps = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce porttitor ut tortor sit amet aliquam. Etiam odio risus, finibus ullamcorper orci quis, mollis consectetur magna. Pellentesque scelerisque turpis ac sapien euismod, sed vestibulum purus dapibus. Etiam vel dictum felis. Vivamus rutrum porta et nunc sit amet tincidunt. Proin molestie mollis et nulla vel rutrum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam vestibulum neque purus, non mollis purus et sagittis a. Fusce tempor efficitur tortor vitae porta. Sed at dui urna. Nam feugiat magna tortor, at blandit magna molestie id. Ut sit amet dui ac diam porttitor vulputate. Cras velit odio, feugiat congue varius nec, dignissim sed est. Mauris commodo accumsan justo a fringilla. Vestibulum eu urna at velit ullamcorper scelerisque. Aliquam dignissim risus nec eros malesuada, id feugiat leo egestas. Sed non imperdiet ipsum. Praesent eu erat ac purus mattis pellentesque. Integer ultricies imperdiet enim, a mattis dolor molestie eget. Nullam est lectus, consequat ut sem sit amet, dapibus commodo erat. Pellentesque porttitor metus a egestas ultricies. Praesent elementum mollis nulla a efficitur. Etiam pellentesque, felis quis hendrerit semper, urna nibh auctor dui, id egestas urna lacus vitae leo. Vivamus consectetur libero in nunc pretium, luctus bibendum elit tincidunt. Ut laoreet tellus sed risus imperdiet, eget condimentum mauris ultricies. Duis consectetur in elit vitae aliquet.Proin tristique, neque id hendrerit molestie, risus nibh pulvinar odio, nec accumsan est turpis vitae lacus. Aenean sapien tortor, hendrerit non lorem eu, laoreet accumsan leo. Praesent consectetur nisl et erat scelerisque ullamcorper. Pellentesque elementum mauris sit amet blandit faucibus. Nullam nunc augue, vulputate tempus tristique eu, dignissim at nisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris luctus lacinia aliquam." countingWords = () => { countingWords()` |
||
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.
Enchainer 3 if fonctionne, pas de soucie la dessus mais ce genre de syntaxe de code est plutot utiliser si il est possible de valider les 3 conditions. Ici on sait que sur les 3 conditions, il n'y en a qu'une seule de possible donc on va privilegier if elseif else.