1、toUpperCase()   方法用于把字符串转换为大写

var str = prompt("请输入需转换大写的字符串:");

str = str.toUpperCase();

console.log(str);

 

toUpperCase 方法

  1. 返回一个字符串,该字符串中的所有字母都被转化为大写字母。
  2. 对非字母字符不会产生影响。

2、toLowerCase()    方法用于把字符串转换为大写

var str = prompt("请输入需转换大写的字符串:");

str = str.toLowerCase();

console.log(str);

toLowerCase 方法

  1. 返回一个字符串,该字符串中的字母被转换为小写字母。
  2. 对非字母字符不会产生影响。

3、番外篇

运用操作字符concat(连接字符串),slice(截取字符串)、以及charAt(给索引查字符)和indexOf(给字符查索引)实现输入英文首字母大写。

var strs = prompt("请在下方输入英文句子:");   //将输入内容赋值给strs

var First = strs.charAt(0).toUpperCase();//给索引为0的字符大写

s = strs.indexOf(".");                 //从这段话开头开始,查找字符为英文。的第一个索引

cvs =strs.slice(1,s).toLowerCase();   //截取这段话剩余单词全部转小写
console.log(First.concat(cvs));      //连接字符串并于控制台打印

最新文章

  1. Reporting Services 错误案例一则
  2. Codeforces Round #371 (Div. 1)
  3. runtime学习实战一:类的属性进行归档解档
  4. AndroidManifest.xml的android:name是否带.的区别
  5. 对于大一学习计算机的新手(c/c++ )提出一些学习经验
  6. .Net性能优化时应该关注的数据
  7. BootStrap2学习日记3--响应式布局实用类
  8. SQLite 入门教程(一)基本控制台(终端)命令 (转)
  9. webkit中DOM 事件有多少
  10. spark二次排序
  11. (转)在Eclipse中使用JUnit4进行单元测试
  12. Spring IOC之Bean 概述
  13. js 获取n天前的时间
  14. MyBatis 的小细节问题
  15. 解决 Cannot find OpenSSL's <evp.h> 和sasl.h not found!
  16. 设置Mac 终端走代理
  17. zabbix监控特定脚本有无生成
  18. Servlet交互与JSP
  19. 在Visual Stdio 2012中编译执行JM18.6的方法
  20. Java设计模式应用——工厂模式

热门文章

  1. java中Logger.getLogger(Test.class),即log4日志的使用
  2. SQL使用union合并查询结果(转载)
  3. 170324、Spring 处理器和Resource
  4. java nio探险
  5. CodeForces 732C Sanatorium
  6. python AI(numpy,matplotlib)
  7. Python进阶知识
  8. Python3: Command not found(Mac OS)
  9. leetcode_Basic Calculator
  10. 14.Iterate a Cursor in the mongo Shell-官方文档摘录