当前位置:网站首页>leetcode-520. Detect capital letters -js
leetcode-520. Detect capital letters -js
2022-07-07 23:15:00 【Qianfan at the front】
subject 
Code
/** * @param {string} word * @return {boolean} */
var detectCapitalUse = function(word) {
// There is only one letter , Returns... Regardless of case true
if (word.length === 1) return true
const upperStr = word.toUpperCase()
const lowerStr = word.toLowerCase()
if (word === upperStr || word === lowerStr) {
// When all letters are uppercase or lowercase
return true;
} else if (word[0] <= 'Z' && word[0] >= 'A' && word.slice(1) === lowerStr.slice(1)) {
// When the first letter is capitalized , When all other letters are lowercase
return true
}
return false
};
边栏推荐
- 定位到最底部[通俗易懂]
- CXF call reports an error. Could not find conduct initiator for address:
- PMP项目管理考试过关口诀-1
- Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to jsp-2
- kubernetes的简单化数据存储StorageClass(建立和删除以及初步使用)
- 网络安全-安装CentOS
- Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
- USB(十五)2022-04-14
- 为什么市场需要低代码?
- 网络安全-CSRF
猜你喜欢

PCL . VTK files and Mutual conversion of PCD

Specific method example of V20 frequency converter manual automatic switching (local remote switching)

Technology at home and abroad people "see" the future of audio and video technology

JMeter-接口自动化测试读取用例,执行并结果回写

Cases of agile innovation and transformation of consumer goods enterprises

Talk about the design and implementation logic of payment process

Wechat forum exchange applet system graduation design completion (1) development outline

二叉树(Binary Tree)

微信论坛交流小程序系统毕业设计毕设(6)开题答辩PPT

Transform XL translation
随机推荐
Byte hexadecimal binary understanding
648. 单词替换
【编译原理】词法分析设计实现
Clean C disk
Quelles sont les similitudes et les différences entre les communautés intelligentes et les villes intelligentes?
ArcGIS: field assignment_ The attribute table field calculator assigns values to fields based on conditions
网络安全-CSRF
微信论坛交流小程序系统毕业设计毕设(7)中期检查报告
Txt file virus
Unity dynamically merges mesh textures
智慧社區和智慧城市之間有什麼异同
Brush question 5
USB (十七)2022-04-15
Cases of agile innovation and transformation of consumer goods enterprises
Gbu1510-asemi power supply special 15A rectifier bridge gbu1510
2021-01-12
Lecture 30 linear algebra Lecture 5 eigenvalues and eigenvectors
Install Fedora under RedHat
The 19th Zhejiang Provincial Collegiate Programming Contest 2022浙江省赛 F.EasyFix 主席树
Statistical method for anomaly detection