-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsograms
More file actions
22 lines (15 loc) · 708 Bytes
/
Isograms
File metadata and controls
22 lines (15 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.
Example: (Input --> Output)
"Dermatoglyphics" --> true
"aba" --> false
"moOse" --> false (ignore letter case)
========================
function isIsogram(str){
return new Set(str.toUpperCase()).size == str.length;
}
===========================
Explaination
.toUpperCase() - puts all str from the parameter to uppercase.
New Set() - removes any duplicates from str so e.g "MOOSE" == "MOSE"
Set.size - how many unique letters
str.length = how many total letters