From 1d24bc0e13495d5c12f2bab64766e1d366ac03bd Mon Sep 17 00:00:00 2001 From: Yuya Minamide Date: Sun, 11 Jun 2023 18:13:42 -0700 Subject: [PATCH] solved 520. Detect Capital --- 520.detect-capital.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 520.detect-capital.js diff --git a/520.detect-capital.js b/520.detect-capital.js new file mode 100644 index 0000000..923cd2a --- /dev/null +++ b/520.detect-capital.js @@ -0,0 +1,18 @@ +/** + * URL of this problem + * https://leetcode.com/problems/detect-capital/ + */ + +/** + * @param {string} word + * @return {boolean} + */ +var detectCapitalUse = function (word) { + const AllCapitalLetter = word.toUpperCase(); + const AllLowerCaseLetter = word.toLowerCase(); + const FirstCapitalLetter = word.charAt(0).toUpperCase() + AllLowerCaseLetter.slice(1); + + if (AllCapitalLetter === word || AllLowerCaseLetter === word || FirstCapitalLetter === word) return true; + + return false; +};