当前位置:网站首页>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
};
边栏推荐
- ArcGIS:字段赋值_属性表字段计算器(Field Calculator)依据条件为字段赋值
- Byte hexadecimal binary understanding
- 智慧社區和智慧城市之間有什麼异同
- The 19th Zhejiang Provincial Collegiate Programming Contest 2022浙江省赛 F.EasyFix 主席树
- Inftnews | web5 vs Web3: the future is a process, not a destination
- Wechat forum exchange applet system graduation design completion (8) graduation design thesis template
- 每日一题——PAT乙级1002题
- Txt file virus
- ArcGIS: field assignment_ The attribute table field calculator assigns values to fields based on conditions
- Clean C disk
猜你喜欢
Specific method example of V20 frequency converter manual automatic switching (local remote switching)
U盘拷贝东西时,报错卷错误,请运行chkdsk
Matlab 信号处理【问答随笔·2】
十四、数据库的导出和导入的两种方法
STL标准模板库(Standard Template Library)一周学习总结
iNFTnews | NFT技术的广泛应用及其存在的问题
数据库每日一题---第22天:最后一次登录
Innovation today | five key elements for enterprises to promote innovation
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
How to operate DTC community?
随机推荐
Network security - Eternal Blue
Mitsubishi PLC SLmP (MC) protocol
2021ICPC上海 H.Life is a Game Kruskal重构树
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
Network security CSRF
Redhat下安装fedora
Advantages and disadvantages of rest ful API
网络安全-CSRF
iNFTnews | NFT技术的广泛应用及其存在的问题
Grid
[network] Introduction to C language
Byte hexadecimal binary understanding
Kubernetes' simplified data storage storageclass (creation, deletion and initial use)
十三、系统优化
网络安全-burpsuit
为什么市场需要低代码?
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
php 使用阿里云存储
One question per day - pat grade B 1002 questions
V20变频器手自动切换(就地远程切换)的具体方法示例