当前位置:网站首页>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
};
边栏推荐
- 软件测评中心▏自动化测试有哪些基本流程和注意事项?
- Interview questions: how to test app performance?
- 嵌入式音频开发中的两种曲线
- 30讲 线性代数 第五讲 特征值与特征向量
- LeetCode206. Reverse linked list [double pointer and recursion]
- LeetCode203. Remove linked list elements
- Debezium series: introducing support for the final operator
- Anta DTC | Anta transformation, building a growth flywheel that is not only FILA
- Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to jsp-2
- De la famille debezium: SET ROLE statements supportant mysql8
猜你喜欢

Transparent i/o model from beginning to end

GBU1510-ASEMI电源专用15A整流桥GBU1510

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

What is fake sharing after filling the previous hole?
![Leetcode19. Delete the penultimate node of the linked list [double pointer]](/img/a9/809b93d1ffd11ba4a9074ac8e2bdee.jpg)
Leetcode19. Delete the penultimate node of the linked list [double pointer]

Innovation today | five key elements for enterprises to promote innovation

行测-图形推理-7-相异图形类

Line test - graphic reasoning - 3 - symmetric graphic class

Comparison of various development methods of applets - cross end? Low code? Native? Or cloud development?

聊聊 Dart 的空安全 (null safety) 特性
随机推荐
One question per day - pat grade B 1002 questions
数据库每日一题---第22天:最后一次登录
ArcGIS:字段赋值_属性表字段计算器(Field Calculator)依据条件为字段赋值
Database daily question --- day 22: last login
GBU1510-ASEMI电源专用15A整流桥GBU1510
Exploratory data analysis of heartbeat signal
JS triangle
Line test graph reasoning graph group class
Line test - graphic reasoning - 4 - alphabetic class
Basic knowledge of linked list
Are the microorganisms in the intestines the same as those on the skin?
Line test - graphic reasoning - 1 - Chinese character class
Sword finger offer 27 Image of binary tree
Byte hexadecimal binary understanding
微信论坛交流小程序系统毕业设计毕设(2)小程序功能
This time, let's clear up: synchronous, asynchronous, blocking, non blocking
Personal statement of testers from Shuangfei large factory: is education important for testers?
网络安全-CSRF
网络安全-burpsuit
GEE(四):计算两个变量(影像)之间的相关性并绘制散点图