From ad79909c2e24660dd5420798040516a0b2843042 Mon Sep 17 00:00:00 2001 From: Nishanth2143 Date: Sun, 11 Oct 2020 14:16:18 +0530 Subject: [PATCH] removed isogram --- snippets/isIsogram.md | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 snippets/isIsogram.md diff --git a/snippets/isIsogram.md b/snippets/isIsogram.md deleted file mode 100644 index ba554c229..000000000 --- a/snippets/isIsogram.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: isIsogram -tags: string, intermediate ---- - -Creates a function that accepts a string parameter and output whether its an isogram or not. - -- Use `String.toLowerCase()` to convert the string to lowercase letters. -- Use `String.prototype.split()`, `String.prototype.indexOf()` and `Array.prototype.every()` to split the string into substrings, run a test for all the elements in that array and finally return the index of first occurence of a specified value in a string. -- Function returns true if the string is an isogram (that is no letter is repeated) else returns false. -- Returns false if called with no parameter. - -```js -const isIsogram = (str = null) => { - if(str == null) return false; - str = str.toLowerCase(); - return str.split("").every((c, i) => str.indexOf(c) === i); -} -``` - -```js -isIsogram("Dermatoglyphics"); // true -isIsogram("aba"); // false -isIsogram("moOse"); // false -isIsogram(); // false -```