Show HTML Codings not the words? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Show HTML Codings not the words?

I have made a programme in javascript.Details are given here:- i enter a string/chrachter or paragraph and the programme will convert it to html codes for example : I enter "ABCD" and programm will give me the values "&#65;&#66;&#67;&#68;" but when i run the programme in browser this prints "ABCD" rather html codes. So the Question is how to show codes in browser rather than Alphabets. my code is <script type="text/javascript"> var str = 'ABCD'; for (var i = 0; i < str.length; i++) { var arr=new Array(str.charAt(i)); var alpha =[]; alpha["A"]="&#65;"; alpha["B"]="&#66;"; alpha["C"]="&#67;"; alpha["D"]="&#68;"; for(j=0;j<arr.length;j++){ document.write(alpha[arr[j]]); } } </script>

12th Aug 2018, 2:45 PM
Amir Ahmad
Amir Ahmad - avatar
4 Answers
+ 3
i have solved the problem see my code https://code.sololearn.com/Wao18gdsAVQm
23rd Aug 2018, 9:15 PM
Amir Ahmad
Amir Ahmad - avatar
+ 4
because document.write is something like html eval
12th Aug 2018, 3:00 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 4
push results into an array then use alert or console.log I don't know which work though
12th Aug 2018, 3:13 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
Mert Yazıcı Mert Yazici so how to write it?
12th Aug 2018, 3:11 PM
Amir Ahmad
Amir Ahmad - avatar