DEV Community

loading...

Discussion on: Daily Challenge #304 - Consecutive Letters

Collapse
sabbin profile image
Sabin Pandelovitch

Javascript with less complexity

function solve(str) {
  let status = true;
  let counter = 1;
  while (status && counter < str.length) {
    status = str.charCodeAt(counter) === str.charCodeAt(counter-1)+1;
    counter++;
  }
  return status;
}
Enter fullscreen mode Exit fullscreen mode