+ 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)
3 Answers
+ 4
One = is an assignment operator.
You should use === in your control flow statements
âșïžâșïž
+ 2
You have to use "else" in the last case.
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