一段语句 每个单词 基数位大写,偶数位小写
2017-01-13 15:25
246 查看
function toWeirdCase(string){ return string.split(' ').map(function(word){ console.log(word) return word.split('').map(function(letter, index){ return index % 2 == 0 ? letter.toUpperCase() : letter.toLowerCase() }).join(''); }).join(' '); } console.log(toWeirdCase("this is big"));如:this is big 输出:ThIs Is BiG
相关文章推荐
- 将一段英文每个单词首字母大写
- python title() upper() lower() 以首字母大写的方式显示每个单词/将字符串改为全部大写或全部小写
- Python3基础 str title 把字符串中的每个单词首写字母变为大写其余均为小写
- 将一段英语的每个单词首字母大写
- Java 读取一段英文文档统计每个单词出现的次数和单词的总数
- 有一段文本,将文本中的所有单词,存放到一个字符指针数组中(要求每个单词内存恰好)
- 如何使字符串中每隔单词的首字母大写,其余部分小写?
- js将字符串中的每一个单词的首字母变为大写其余均为小写
- 将一段话的每个单词首字母大写
- [Go] 第一个单词首字母变大写:Ucfirst(),第一个单词首字母变小写:Lcfirst()
- 2、有一段文本,将文本中的所有单词,存放到一个字符指针数组中(要求每个单词内存恰好)。
- 怎么把某字段单词的首字母改为大写其它小写?
- 串的处理 在实际的开发工作中,对字符串的处理是最常见的编程任务。本题目即是要求程序对用户输入的串进行处理。具体规则如下: 1. 把每个单词的首字母变为大写。 2. 把数字与字母之间用下划线字符(_)分
- 将字符串中由空格隔开的每个单词首字母大写
- 67.读入字符串把每个单词开始的字母大写
- Java-单词首字母小写变大写
- // 2、有一段文本,将文本中的所有单词,存放到一个字符指针数组中(要求每个单词内存恰好)。
- 有一段文本,将文本中的所有单词,存放到一个字符指针数组中(要求每个单词内存恰好)。
- PHP 大小写转换、首字母大写、每个单词首字母大写转换相关函数
- 读取一段文档,输出每个单词出现的频率,并且把出现频率最高的十个单词输出。