Paris FTWD - Camille&Camille - Basic algorithms done#397
Conversation
| let lettres = "" | ||
|
|
||
| for(i = 0; i < hacker1.length; i++) { | ||
| console.log(lettres += hacker1.charAt(i).toUpperCase() + " ") |
There was a problem hiding this comment.
Care, here you are doing a console log inside a loop, so you will print something at every round of the loop. It is a good idea to start from letter which is empty and add letters to it ! The console log should be right after ;)
| } | ||
|
|
||
| for(i = hacker2.length; i >= 0; i--) { | ||
| console.log(lettres += hacker2.charAt(i)) |
There was a problem hiding this comment.
Here, lettres has kept in memory the hacker1 letters because the scope is the same and you use +=. Maybe try this in to separate functions or assign a new variable, or start back letter empty :-)
| } | ||
| console.log("The text contains " + counter + " words."); | ||
|
|
||
| var n = text.search("et"); |
There was a problem hiding this comment.
POUR .search() / Si la recherche aboutit, search() renvoie un entier qui correspond à l'indice de la première correspondance trouvée dans la chaîne. Du coup pas sur que ca soit l'outil adequate ici ;)
Une facon de le faire
var count = 0; for (let i = 0; i < loremIps.split(" ").length; i++) { if(loremArr[i] === "et") { count += 1 } }
|
Bon travail dans l'ensemble ! Well done ! |
No description provided.