Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, May 13, 2017

FreeCodeCamp Convert HTML Entities Sample Solution


function convertHTML(str) {
  // :)
  var htmlCode = {
    "&":"&",
    "<":"&lt;",
    ">":"&gt;",
    "\"":"&quot;",
    "'":"&apos;"
  };
  var arrayStr = str.split('');
  for(var i in arrayStr){
    for(var j in htmlCode){
      if(arrayStr[i] == j){
        arrayStr[i] = htmlCode[j];
      }
    }
  }
  return arrayStr.join('');
}

convertHTML("Dolce & Gabbana");

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts