Skip to content

Instantly share code, notes, and snippets.

@spences10

spences10/paste.js

Last active Feb 21, 2017
Embed
What would you like to do?
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