Help (javascript code) | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Help (javascript code)

Hello, can anyone tell me if this code is correct? The function must return the string parameter, and must replace the e's with 3's, the i's with 1's and the o's with 0's. On a site it said it was good but I have a big doubt unless there are several ways to do it. Help me please!

15th Oct 2022, 2:52 PM
Laïla M
Laïla M - avatar
5 Antworten
+ 1
could you link your code so we can have a look?
15th Oct 2022, 3:33 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 1
// Output: S0l0L3arn function rep(s){ s = s.replaceAll('e', '3'); s = s.replaceAll('i', '1'); s = s.replaceAll('o', '0'); return s } console.log( rep("SoloLearn") );
15th Oct 2022, 4:27 PM
SoloProg
SoloProg - avatar
+ 1
Thank you! But I don't why on the site they said that my code was correct :/ do they're differents methods to use?
15th Oct 2022, 8:47 PM
Laïla M
Laïla M - avatar
+ 1
No problem 👍👍
15th Oct 2022, 8:51 PM
SoloProg
SoloProg - avatar
0
Apollo-Roboto sorry I forget to add my code : function remplacerLesLettres($string){ return $string if(varchar = e) return 3; if(varchar = i) return 1; if(varchar = o) return 0; }
15th Oct 2022, 3:36 PM
Laïla M
Laïla M - avatar