Skip to content

Instantly share code, notes, and snippets.

@spences10
Last active February 21, 2017 15:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save spences10/82c601c26aa2f0b609a2d1d7148c3db7 to your computer and use it in GitHub Desktop.
function convertHTML (str) {
let loopString = str
for (let char of loopString) {
console.log(char)
switch (char) {
case '<':
char = '&lt'
break
case '&':
char.char = '&amp'
break
case '>':
char = '&gt'
break
case '"':
char = '&quot'
break
case "'":
char = '&apos'
break
}
}
loopString.split('')
return loopString
}
convertHTML('Dolce & Gabbana')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment