diff --git a/Javascript/program-11/program.js b/Javascript/program-11/program.js new file mode 100644 index 00000000..e828ece4 --- /dev/null +++ b/Javascript/program-11/program.js @@ -0,0 +1,14 @@ +const isIsogram = str => { + str = str.toLowerCase(); + for (let i=0 ; str.length > i ; i++){ + for(let j=1+i ; str.length > j ; j++ ){ + if ( str[i]==str[j] ){ + return false; + } + } + } + return true; +} + +//isIsogram('isogram'); // true +//isIsogram('isIsogram'); // false \ No newline at end of file diff --git a/Javascript/program-11/readme.md b/Javascript/program-11/readme.md new file mode 100644 index 00000000..f60a6716 --- /dev/null +++ b/Javascript/program-11/readme.md @@ -0,0 +1,11 @@ +--- +title: isIsogram +tags: string,begginer +--- + +Checks if a given word is an isogram or not. An isogram is a word that has no repeating letters. + +- Convert string to `lowercase`/`uppercase` since capital letters do not equate to small letter. +- Iterate the string using 2 for loops using the iterators `i` and `j`. Where `j` starts of 1 more than `i`. +- If at any point `str[i]` is equal to `str[j]` return `false`. +- If the above does not happen till you reach the end of the string return `true`.