Link to home
Start Free TrialLog in
Avatar of juan field
juan field

asked on

how can i check if the text is an Isogram ?

THIS IS WHAT I HAVE SO FAR :

///////////////////////////////////////////////////////////////////////

function isIsogram(text) {
  // add each char to a set
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
  // note: a set drops dup values
  // thus, to see if all the chars were unique,
  // check length of text and the size of the set
 
 
  var splittedText = text.split("");
  text.forEach(function(element){
      if(element.repeat(1) === true || text.length === 0)
      return true;
      else
      return false;
  });
 
}


console.log(isIsogram("abc"))
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of juan field
juan field

ASKER

I was not aware that Set doesn't accept duplicate. Thank you hielo.