View on GitHub

marymafa.github.io


layout: post title: Convert HTML Entities date: 2017-11-10 —

Convert HTML Entities

About HTML ENTITIES

An HTML entity is a piece of text (“string”) that begins with an ampersand (&) and ends with a semicolon (;) . Entities are frequently used to display reserved characters (which would otherwise be interpreted as HTML code), and invisible characters (like non-breaking spaces).

Intructions:

Convert the characters &, <, >, “ (double quote), and ‘ (apostrophe), in a string to their corresponding HTML entities.

Problem started

When my switch statement returns wrong results. But i did my best to make sure that it will execute good results.

Solution

I firstly created for loop so that the values will iterated. I used switch statement to perform different actions based on different conditions. And on my switch statement , each case were suppose to output difference conditions.

And this is how it works:

1.The switch expression is evaluated once.

2.The value of the expression is compared with the values of each case.

3.If there is a match, the associated block of code is execute