Hello World


Can’t not title the first post ‘Hello World’!
/**
 * Checks if a string contains exactly seven occurrences of the word "Pigs"
 * @param {string} text - The input string to check
 * @returns {boolean} True if exactly seven occurrences are found
 * @throws {TypeError} If the input is not a string
 */
const confirmSevenPigs = (text) => {
  if (typeof text !== "string") {
    throw new TypeError("Input must be a string");
  }

  // Using regex with word boundaries to match exact word "Pigs"
  const pigMatches = text.match(/\bPigs\b/g);

  // If no matches found, return false (avoid null check)
  return (pigMatches?.length ?? 0) === 7;
};