Files
2023-01-30 18:58:54 +02:00

1.4 KiB
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
af7588ade1100bde429baf20 Пропущені літери 1 16023 missing-letters

--description--

Знайдіть пропущену літеру в переданому діапазоні літер та поверніть її.

Якщо у діапазоні наявні всі літери, поверніть undefined.

--hints--

fearNotLetter("abce") має повертати рядок d.

assert.deepEqual(fearNotLetter('abce'), 'd');

fearNotLetter("abcdefghjklmno") має повертати рядок i.

assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i');

fearNotLetter("stvwx") має повертати рядок u.

assert.deepEqual(fearNotLetter('stvwx'), 'u');

fearNotLetter("bcdf") має повертати рядок e.

assert.deepEqual(fearNotLetter('bcdf'), 'e');

fearNotLetter("abcdefghijklmnopqrstuvwxyz") має повертати undefined.

assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'));

--seed--

--seed-contents--

function fearNotLetter(str) {
  return str;
}

fearNotLetter("abce");

--solutions--

function fearNotLetter (str) {
  for (var i = str.charCodeAt(0); i <= str.charCodeAt(str.length - 1); i++) {
    var letter = String.fromCharCode(i);
    if (str.indexOf(letter) === -1) {
      return letter;
    }
  }

  return undefined;
}