From 04f773f0543844beb22bc56cee2c62b5f8524c15 Mon Sep 17 00:00:00 2001 From: fauwara Date: Thu, 29 Oct 2020 22:00:10 +0400 Subject: [PATCH] Created program-11 --- Javascript/program-11/program.js | 14 ++++++++++++++ Javascript/program-11/readme.md | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Javascript/program-11/program.js create mode 100644 Javascript/program-11/readme.md 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`.