freeCodeCamp:Convert HTML Entities
将字符串中的字符 &、<、>、" (双引号), 以及 '(单引号)转换为它们对应的 HTML 实体。
现在这个表里找出要转化的符号https://dev.w3.org/html5/html-author/charref
function convert(str) {
var obj={
"&":'&',
'<':'<',
'>':'>',
'"':'"',
"'":'''
};
var arr = str.split("");
var result = arr.map(function(val){
if(obj.hasOwnProperty(val)){
return obj[val];
}else{
return val;
}
});
return result.join("");
}
convert("Dolce & Gabbana");
freeCodeCamp:Convert HTML Entities的更多相关文章
- FCC-学习笔记 Convert HTML Entities
FCC-学习笔记 Convert HTML Entities 1>最近在学习和练习FCC的题目.这个真的比较的好,推荐给大家. 2>中文版的地址:https://www.freecode ...
- Convert HTML Entities
function convert(str) { // :) //return str; var HTML_Entities = { '&':'&', '<':'<', '& ...
- FreeCodeCamp 中级算法(个人向)
freecodecamp 中级算法地址戳这里 Sum All Numbers in a Range 我们会传递给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. function su ...
- Convert HTML Entities-freecodecamp算法题目
Convert HTML Entities 1.要求 将字符串中的字符 &.<.>." (双引号), 以及 ' (单引号)转换为它们对应的 HTML 实体. 2.思路 利 ...
- FCC-js算法题解题笔记
题目链接:https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm ...
- PHP清理跨站XSS xss_clean 函数 整理自codeigniter Security
PHP清理跨站XSS xss_clean 函数 整理自codeigniter Security 由Security Class 改编成函数xss_clean 单文件直接调用.BY吠品. //来自cod ...
- ABP框架系列之十五:(Caching-缓存)
Introduction ASP.NET Boilerplate provides an abstraction for caching. It internally uses this cache ...
- GeSHi Documentation
GeSHi Documentation Version 1.0.8.11 Authors: © 2004 - 2007 Nigel McNie © 2007 - 2012 Benny Baumann ...
- FCC编程题之中级算法篇(中)
介绍 接着上次的中级算法题 目录 1. Missing letters 2. Boo who 3. Sorted Union 4. Convert HTML Entities 5. Spinal Ta ...
随机推荐
- Keil AGDI Header File
#ifndef __AGDI__INCED___ #define __AGDI__INCED___ //---Revision History: --------------------------- ...
- Freescale OSBDM JM60仿真器
OSBDM-JM60 - 9S08JM60 Based OSBDM — It includes interfaces and firmware applied to all the targets s ...
- codechef Jewels and Stones 题解
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery acces ...
- ASP.NET方面的一些经典文章收集
1. 在ASP.NET中执行URL重写 文章地址:https://msdn.microsoft.com/zh-cn/library/ms972974.aspx 2. 在ASP.NET中如何实现和利用U ...
- 深入了解android平台的jni(二)
Android.mk是Android提供的一种makefile文件,用来指定诸如编译生成so库名.引用的头文件目录.需要编译的.c/.cpp文件和.a静态库文件等.要掌握jni,就必须熟练掌握Andr ...
- Android Studio中导入第三方库
之前开发Android都是使用的eclipse,近期因为和外国朋友Timothy一起开发一款应用,他是从WP平台刚切换使用Android的,使用的开发环境时Android Studio,为了便于项目的 ...
- RMI、RPC、SOAP通讯技术介绍及比对 - XML/SOAP
RMI.RPC.SOAP通信技术介绍及比对 1.RMI 使用java的程序员,对于RMI(RemoteMethod Invoke,远程方法调用)一定不陌生,在java中,为了在分布式应用开发时,能够方 ...
- Android (cocos2dx 网络访问)访问权限设置
Android开发应用程序时,如果应用程序需要访问网络权限,需要在 AndroidManifest.xml 中加入以下代码: 同样的如果用到其它的权限,也需要作出声明,部分权限列表如下: androi ...
- javascript 中 in操作符
in in 操作检查对象中是否有名为 property 的属性.也可以检查对象的原型,以便知道该属性是否为原型链的一部分. 对于一般的对象属性需要用字符串指定属性的名称 var mycar = {ma ...
- 关于egg的压缩测试报告
167274doc 单字分词 全压缩 时间 real 15m58.464suser 13m52.157ssys 2m3.445s 空间 tmpfs 12G 1.5G 11G 13% /ape ...