every with includes

Pangram in JavaScript
export function isPangram(input) {
  const inputLowered = input.toLowerCase();
  return [...'abcdefghijklmnopqrstuvwxyz'].every((c) =>
  • This begins by lowercasing the input by using the String toLowerCase method.
  • It uses spread syntax to make an Array out of a string of the alphabet.
  • It then checks if all letters in the alphabet are contained in the input, using the Array method every with the String method includes.

If all letters of the alphabet are in the input, then the function returns true.

22nd May 2024 · Found it useful?