Mo Zargham 437ba8b103 fix(curriculum): Read-search-ask link now point to correct url as noted in the issue (#37753)
* fix: broken Read-search-ask link now point to correct url

* fix: changed link to original forum link with more views

* fix: changed http links to correct version

* fix: link in help modal
2019-11-19 19:54:48 -05:00

2.0 KiB
Raw Blame History

id, title, isRequired, challengeType, forumTopicId, localeTitle
id title isRequired challengeType forumTopicId localeTitle
af7588ade1100bde429baf20 Missing letters true 5 16023 Пропущенные буквы

Description

Найдите отсутствующую букву в пробе прошедшего письма и верните ее. Если все буквы присутствуют в диапазоне, верните undefined. Не забудьте использовать Read-Search-Ask, если вы застряли. Попробуйте подключить программу. Напишите свой собственный код.

Instructions

Tests

tests:
  - text: <code>fearNotLetter("abce")</code> should return "d".
    testString: assert.deepEqual(fearNotLetter('abce'), 'd');
  - text: <code>fearNotLetter("abcdefghjklmno")</code> should return "i".
    testString: assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i');
  - text: <code>fearNotLetter("stvwx")</code> should return "u".
    testString: assert.deepEqual(fearNotLetter('stvwx'), 'u');
  - text: <code>fearNotLetter("bcdf")</code> should return "e".
    testString: assert.deepEqual(fearNotLetter('bcdf'), 'e');
  - text: <code>fearNotLetter("abcdefghijklmnopqrstuvwxyz")</code> should return undefined.
    testString: assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'));

Challenge Seed

function fearNotLetter(str) {
  return str;
}

fearNotLetter("abce");

Solution

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;
}