mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(curriculum): add Build a Missing Letter Detector lab (#62227)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -3369,6 +3369,12 @@
|
||||
"In this lab, you will implement loops to repeat a string a specified number of times."
|
||||
]
|
||||
},
|
||||
"lab-missing-letter-detector": {
|
||||
"title": "Build a Missing Letter Detector",
|
||||
"intro": [
|
||||
"In this lab, you will build a function that finds the missing letter in a given range of consecutive letters and returns it."
|
||||
]
|
||||
},
|
||||
"review-javascript-loops": {
|
||||
"title": "JavaScript Loops Review",
|
||||
"intro": [
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: Introduction to the Build a Missing Letter Detector
|
||||
block: lab-missing-letter-detector
|
||||
superBlock: full-stack-developer
|
||||
---
|
||||
|
||||
## Introduction to the Build a Missing Letter Detector
|
||||
|
||||
For this lab, you will create a function that finds the missing letter in a given range of consecutive letters and returns it.
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: af7588ade1100bde429baf20
|
||||
title: Build a Missing Letter Detector
|
||||
challengeType: 26
|
||||
dashedName: build-a-missing-letter-detector
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab.
|
||||
|
||||
**User Stories:**
|
||||
|
||||
1. You should have a function named `fearNotLetter`.
|
||||
1. The `fearNotLetter` function should accept one argument: a string representing a range of letters.
|
||||
1. The function should find the missing letter in the passed letter range and return it.
|
||||
1. If all letters are present in the range, the function should return `undefined`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a `fearNotLetter` function.
|
||||
|
||||
```js
|
||||
assert.isFunction(fearNotLetter);
|
||||
```
|
||||
|
||||
`fearNotLetter("abce")` should return the string `d`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(fearNotLetter('abce'), 'd');
|
||||
```
|
||||
|
||||
`fearNotLetter("abcdefghjklmno")` should return the string `i`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i');
|
||||
```
|
||||
|
||||
`fearNotLetter("stvwx")` should return the string `u`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(fearNotLetter('stvwx'), 'u');
|
||||
```
|
||||
|
||||
`fearNotLetter("bcdf")` should return the string `e`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(fearNotLetter('bcdf'), 'e');
|
||||
```
|
||||
|
||||
`fearNotLetter("abcdefghijklmnopqrstuvwxyz")` should return `undefined`.
|
||||
|
||||
```js
|
||||
assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function fearNotLetter (str) {
|
||||
for (var i = str.charCodeAt(0); i <= str.charCodeAt(str.length - 1); i++) {
|
||||
let letter = String.fromCharCode(i);
|
||||
if (str.indexOf(letter) === -1) {
|
||||
return letter;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Build a Missing Letter Detector",
|
||||
"blockType": "lab",
|
||||
"blockLayout": "link",
|
||||
"isUpcomingChange": false,
|
||||
"usesMultifileEditor": true,
|
||||
"dashedName": "lab-missing-letter-detector",
|
||||
"challengeOrder": [
|
||||
{
|
||||
"id": "af7588ade1100bde429baf20",
|
||||
"title": "Build a Missing Letter Detector"
|
||||
}
|
||||
],
|
||||
"helpCategory": "JavaScript"
|
||||
}
|
||||
@@ -366,6 +366,7 @@
|
||||
"lab-chunky-monkey",
|
||||
"lab-profile-lookup",
|
||||
"lab-repeat-a-string",
|
||||
"lab-missing-letter-detector",
|
||||
"review-javascript-loops",
|
||||
"quiz-javascript-loops"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user