Isograms

JavaScript

function isIsogram(str) {
  let existingChars = "";
  str = str.toLowerCase();

  const chars = str.split("");
  for (let i = 0; i < chars.length; i++) {
    const currentChar = chars[i];
    if (existingChars.includes(currentChar)) {
      return false;
    } else {
      existingChars += currentChar;
    }
  }

  return true;
}

Tags

  1. javascript (Private)
  2. 7-kyu (Private)
  3. codewars (Private)
  4. answer (Private)