Detect Pangram(js练习题codewars)

A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant).

Given a string, detect whether or not it is a pangram. Return True if it is, False if not. Ignore numbers and punctuation.

javascript 复制代码
function isPangram(string){
  let abc = 'abcdefghijklmnopqrstuvwxyz'
  let arr = abc.split('');
  str = string.toLowerCase()
  for(let c of str){
    let idx = arr.indexOf(c)
    if(idx > -1){
      arr.splice(idx,1)
    }
    
    if(arr.length == 0){
      return true
    }
  }
  return false
}
相关推荐
掘金安东尼10 小时前
让 JavaScript 更容易「善后」的新能力
前端·javascript·面试
掘金安东尼10 小时前
用 HTMX 为 React Data Grid 加速实时更新
前端·javascript·面试
灵感__idea12 小时前
Hello 算法:众里寻她千“百度”
前端·javascript·算法
yinuo12 小时前
轻松接入大语言模型API -04
前端
袋鼠云数栈UED团队13 小时前
基于 Lexical 实现变量输入编辑器
前端·javascript·架构
cipher13 小时前
ERC-4626 通胀攻击:DeFi 金库的"捐款陷阱"
前端·后端·安全
UrbanJazzerati13 小时前
非常友好的Vue 3 生命周期详解
前端·面试
AAA阿giao13 小时前
从零构建一个现代登录页:深入解析 Tailwind CSS + Vite + Lucide React 的完整技术栈
前端·css·react.js
亦妤13 小时前
JS执行机制、作用域及作用域链
javascript
兆子龙14 小时前
像 React Hook 一样「自动触发」:用 Git Hook 拦住忘删的测试代码与其它翻车现场
前端·架构