+ 2

where is errer? please

var x = "h4ck3r sp34k!!"; for (var i=0; i<x.length; i++) { if (x[i]=4){ x[i]="a"; }else if (x[i]=3){ x[i]="e"; }else if (x[i]=1){ x[i]="i"; }else if (x[i]=3){ x[i]="e"; } }; document.write(x)

7th Oct 2017, 11:51 AM
Laith Mohammed Saker
Laith Mohammed Saker - avatar
3 Answers
+ 4
One = is an assignment operator. You should use === in your control flow statements â˜șâ˜ș
7th Oct 2017, 5:18 PM
Cool Codin
Cool Codin - avatar
+ 2
You have to use "else" in the last case.
7th Oct 2017, 11:55 AM
Saidmamad Gulomshoev
Saidmamad Gulomshoev - avatar
0
Strings cannot me mutated. This means that x[I] cannot be changed. Consequently Javascript throws an error It is not required that you end an if statement with "else" and will not caurse erorrs. It is however good practice as this will catch any missed conditions. @Cool Codin us also correct
7th Oct 2017, 1:30 PM
josh mizzi
josh mizzi - avatar