当前位置:网站首页>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
};
边栏推荐
- 定位到最底部[通俗易懂]
- Network security - Eternal Blue
- 微信论坛交流小程序系统毕业设计毕设(1)开发概要
- [language programming] exe virus code example
- Bit operation
- 十四、数据库的导出和导入的两种方法
- 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
- When copying something from the USB flash disk, an error volume error is reported. Please run CHKDSK
- 十三、系统优化
- Wechat forum exchange applet system graduation design completion (7) Interim inspection report
猜你喜欢

Line test - graphic reasoning - 1 - Chinese character class

The wonderful relationship between message queue and express cabinet

七月第一周

Brush question 3

【刷题记录】3. 无重复字符的最长子串

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

小程序多种开发方式对比-跨端?低代码?原生?还是云开发?

微信论坛交流小程序系统毕业设计毕设(1)开发概要

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

Software test classification
随机推荐
Anta DTC | Anta transformation, building a growth flywheel that is not only FILA
海内外技术人们“看”音视频技术的未来
Install Fedora under RedHat
网络安全-钓鱼
Database daily question --- day 22: last login
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
ArcGIS:字段赋值_属性表字段计算器(Field Calculator)依据条件为字段赋值
14、 Two methods of database export and import
微信论坛交流小程序系统毕业设计毕设(1)开发概要
Mitsubishi PLC SLmP (MC) protocol
About idea cannot find or load the main class
Inftnews | web5 vs Web3: the future is a process, not a destination
Txt file virus
Introduction to redis and jedis and redis things
Introduction to anomaly detection
Network security - joint query injection
网络安全-永恒之蓝
为什么市场需要低代码?
USB (十八)2022-04-17
Byte hexadecimal binary understanding