DEV Community

Discussion on: Daily Challenge #304 - Consecutive Letters

Collapse
 
_bkeren profile image
''

JS

const solve = (string) =>
  string
    .split("")
    .sort()
    .map((i) => i.charCodeAt())
    .every(
      (element, index, array) =>
        index === 0 || array[index] - array[index - 1] === 1
    );

Enter fullscreen mode Exit fullscreen mode