JavaScript: Check a string is a Pangram or not
JavaScript String: Exercise-55 with Solution
A pangram or holoalphabetic sentence is a sentence using every letter of a given alphabet at least once. Pangrams have been used to display typefaces, test equipment, and develop skills in handwriting, calligraphy, and keyboarding.
Write a JavaScript function to check whether a string is a Pangram or not.
Example : "The quick brown fox jumps over the lazy dog"
Test Data:
("The quick brown fox jumps over the lazy dog") -> true
("Waltz, bad nymph, for quick jigs vex.") -> true
("The five boxing wizards jump quickly.") -> true
("The boxing wizards jump quickly.") -> false
(12356) -> "It must be a string."
Sample Solution:
HTML Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript function to Check a string is a Pangram or not</title>
</head>
<body>
</body>
</html>
JavaScript Code:
const test = (string) => {
if (typeof string !== 'string') {
return 'It must be a string.'
}
const result = new Set()
for (const ch of string.toUpperCase())
{
if (/[A-Z]/.test(ch))
{
result.add(ch)
}
}
return result.size === 26
}
console.log(test("The quick brown fox jumps over the lazy dog"))
console.log(test("Waltz, bad nymph, for quick jigs vex."))
console.log(test("The five boxing wizards jump quickly."))
console.log(test("The boxing wizards jump quickly."))
console.log(test(12356))
Sample Output:
true true true false It must be a string.
Flowchart:

Live Demo:
See the Pen javascript-string-exercise-55 by w3resource (@w3resource) on CodePen.
Improve this sample solution and post your code through Disqus
Previous: Check a string is in Kebab case.
Next: Check a string is in Pascal case.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
JavaScript: Tips of the Day
defineProperty method
const person = { name: 'Owen' }; Object.defineProperty(person, 'age', { value: 21 }); console.log(person); console.log(Object.keys(person));
With the defineProperty method, we can add new properties to an object, or modify existing ones. When we add a property to an object using the defineProperty method, they are by default not enumerable. The Object.keys method returns all enumerable property names from an object, in this case only "name".
Properties added using the defineProperty method are immutable by default. You can override this behavior using the writable, configurable and enumerable properties. This way, the defineProperty method gives you a lot more control over the properties you're adding to an object.
Ref: https://bit.ly/323Y0P6
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook