Skip to content

Paris FTWD - Camille&Camille - Basic algorithms done#397

Closed
camcharp wants to merge 1 commit into
ironhack-labs:masterfrom
camcharp:master
Closed

Paris FTWD - Camille&Camille - Basic algorithms done#397
camcharp wants to merge 1 commit into
ironhack-labs:masterfrom
camcharp:master

Conversation

@camcharp
Copy link
Copy Markdown

No description provided.

let lettres = ""

for(i = 0; i < hacker1.length; i++) {
console.log(lettres += hacker1.charAt(i).toUpperCase() + " ")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 } }

@ta-web-paris
Copy link
Copy Markdown

Bon travail dans l'ensemble ! Well done !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants