function convertToHacker(str){
for (var i=0; i <str.length;i++)
{
if (str[i]==="a")
{str=str.replace("a","4")}
else if (str[i]==="e")
{str=str.replace("e","3")}
else if (str[i]==="i")
{str=str.replace("i","1")}
else if (str[i]==="o")
{str=str.replace("o","0")}
else if (str[i]==="s")
{str=str.replace("s","5")}
else {}
}
return str
}
document.write (convertToHacker("become a coder"))
The output is not as expected and upon checking the code, it seems there are issues with comparison operators ('=' instead of '=='). The function should replace all 'a's with 4, 'e's with 3, 'i's with 1, 'o's with 0, and 's's with 5.