Skip to content

Instantly share code, notes, and snippets.

@minsooshin
Last active November 22, 2015 04:01
Show Gist options
  • Save minsooshin/54ce473934578c550df8 to your computer and use it in GitHub Desktop.
Save minsooshin/54ce473934578c550df8 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Convert HTML Entities
// Bonfire: Convert HTML Entities
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-convert-html-entities
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function convert(str) {
// :)
return str.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
}
convert("Dolce & Gabbana");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment