* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.3 KiB
1.3 KiB
id, title, challengeType, dashedName
id | title | challengeType | dashedName |
---|---|---|---|
af7588ade1100bde429baf20 | 寻找缺失的字母 | 5 | 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;
}