I'm trying to solve a fairly simple kata and find myself stuck to a conditional. I'm trying to return the same integer for a string that has the same letter more than once.
For example, for the string hello
it should return 0.1.2.2.3
.
This is my code so far:
const wordPattern = word => {
word = word.toLowerCase();
let index =[]
for(i=0; i<word.length; i++){
index.includes(i) ? word(i) === index[i] : index.push(i)
}
return index
}
Thanks a lot in advance!
Aucun commentaire:
Enregistrer un commentaire