Just a quick update for those having this issue. I gave up and left it as it was. In that article on the php academy site, the OP displayed his results and his solution and not even that worked, or at least not for me. It kept taking the whole string of page content smiley and all and replacing it on the page instead of just sticking the smiley in there.
And as far as the other examples, i also could not get them to work. Its probably me im not good with js but i wanted to update here in case so you dont get frustrated when it does not work for you either.
So i put it back the way it was and i figure if they want to put a smiley someplace other than the end of the line, they can copy and paste the smiley code where they want in the text... lol
Peace