当前位置:网站首页>leetcode-520. 检测大写字母-js
leetcode-520. 检测大写字母-js
2022-07-07 21:50:00 【前端千帆】
题目
代码
/** * @param {string} word * @return {boolean} */
var detectCapitalUse = function(word) {
// 只有一个字母,不管大小写都返回 true
if (word.length === 1) return true
const upperStr = word.toUpperCase()
const lowerStr = word.toLowerCase()
if (word === upperStr || word === lowerStr) {
// 当全部字母都是大写或者小写时
return true;
} else if (word[0] <= 'Z' && word[0] >= 'A' && word.slice(1) === lowerStr.slice(1)) {
// 当首字母是大写,其他字母都是小写时
return true
}
return false
};
边栏推荐
猜你喜欢

Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
![LeetCode142. Circular linked list II [two pointers, two methods for judging links in the linked list and finding ring points]](/img/5e/e442c8649b9123a9d9df7c0d61a564.jpg)
LeetCode142. Circular linked list II [two pointers, two methods for judging links in the linked list and finding ring points]

iNFTnews | Web5 vs Web3:未来是一个过程,而不是目的地

行测-图形推理-5-一笔画类

Basic knowledge of linked list

iNFTnews | NFT技术的广泛应用及其存在的问题

Why is network i/o blocked?
![Cause analysis and solution of too laggy page of [test interview questions]](/img/33/2c2256fd98b908ddaf5573f644ad7f.png)
Cause analysis and solution of too laggy page of [test interview questions]

Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?

线上面试,该如何更好的表现自己?这样做,提高50%通过率~
随机推荐
Installing vmtools is gray
Transform XL translation
行测-图形推理-8-图群类
iNFTnews | Web5 vs Web3:未来是一个过程,而不是目的地
[network] Introduction to C language
网络安全-CSRF
Byte hexadecimal binary understanding
Database daily question --- day 22: last login
软件测评中心▏自动化测试有哪些基本流程和注意事项?
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
De la famille debezium: SET ROLE statements supportant mysql8
安踏DTC | 安踏转型,构建不只有FILA的增长飞轮
ASEMI整流桥KBPC1510的型号数字代表什么
Classification and prediction of heartbeat signal
Lecture 30 linear algebra Lecture 5 eigenvalues and eigenvectors
JS triangle
嵌入式音频开发中的两种曲线
Understand the session, cookie and token at one time, and the interview questions are all finalized
今日创见|企业促进创新的5大关键要素
Talk about DART's null safety feature