当前位置:网站首页>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
};
边栏推荐
猜你喜欢
Wechat forum exchange applet system graduation design (5) assignment
Innovation today | five key elements for enterprises to promote innovation
Are the microorganisms in the intestines the same as those on the skin?
Wechat forum exchange applet system graduation design completion (8) graduation design thesis template
Talk about DART's null safety feature
PCL . VTK files and Mutual conversion of PCD
Unity3D学习笔记5——创建子Mesh
Wechat forum exchange applet system graduation design completion (4) opening report
Matlab-SEIR传染病模型预测
聊聊 Dart 的空安全 (null safety) 特性
随机推荐
GEE(四):计算两个变量(影像)之间的相关性并绘制散点图
聊聊支付流程的设计与实现逻辑
成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚
高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
网格(Grid)
Quelles sont les similitudes et les différences entre les communautés intelligentes et les villes intelligentes?
leetcode-520. 检测大写字母-js
Database daily question --- day 22: last login
Some parameters of Haikang IPC
Innovation today | five key elements for enterprises to promote innovation
Unity3D学习笔记6——GPU实例化(1)
648. 单词替换
定位到最底部[通俗易懂]
Brush question 3
Talk about the design and implementation logic of payment process
Comparison of various development methods of applets - cross end? Low code? Native? Or cloud development?
Network security -burpsuit
Network security CSRF
Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to jsp-2