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
}
相关推荐
阿珊和她的猫4 小时前
React Hooks:革新组件开发的优势与实践
前端·react.js·状态模式
全栈技术负责人4 小时前
AI时代前端工程师的转型之路
前端·人工智能
TDengine (老段)4 小时前
TDengine Python 连接器入门指南
大数据·数据库·python·物联网·时序数据库·tdengine·涛思数据
花归去4 小时前
echarts 柱状图曲线图
开发语言·前端·javascript
喝拿铁写前端4 小时前
当 AI 会写代码之后,我们应该怎么“管”它?
前端·人工智能
老前端的功夫4 小时前
TypeScript 类型魔术:模板字面量类型的深层解密与工程实践
前端·javascript·ubuntu·架构·typescript·前端框架
萧曵 丶4 小时前
事务ACID特性详解
数据库·事务·acid
Nan_Shu_6144 小时前
学习: Threejs (2)
前端·javascript·学习
G_G#5 小时前
纯前端js插件实现同一浏览器控制只允许打开一个标签,处理session变更问题
前端·javascript·浏览器标签页通信·只允许一个标签页
kejiayuan5 小时前
CTE更易懂的SQL风格
数据库·sql