dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
111 lines
3.1 KiB
Markdown
111 lines
3.1 KiB
Markdown
---
|
|
id: 56533eb9ac21ba0edf2244bb
|
|
title: Word Blanks
|
|
challengeType: 1
|
|
forumTopicId: 18377
|
|
dashedName: word-blanks
|
|
---
|
|
|
|
# --description--
|
|
|
|
You are provided sentences with some missing words, like nouns, verbs, adjectives and adverbs. You then fill in the missing pieces with words of your choice in a way that the completed sentence makes sense.
|
|
|
|
Consider this sentence:
|
|
|
|
```md
|
|
It was really ____, and we ____ ourselves ____.
|
|
```
|
|
|
|
This sentence has three missing pieces- an adjective, a verb and an adverb, and we can add words of our choice to complete it. We can then assign the completed sentence to a variable as follows:
|
|
|
|
```js
|
|
const sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselves " + "silly" + ".";
|
|
```
|
|
|
|
# --instructions--
|
|
|
|
In this challenge, we provide you with a noun, a verb, an adjective and an adverb. You need to form a complete sentence using words of your choice, along with the words we provide.
|
|
|
|
You will need to use the string concatenation operator `+` to build a new string, using the provided variables: `myNoun`, `myAdjective`, `myVerb`, and `myAdverb`. You will then assign the formed string to the `wordBlanks` variable. You should not change the words assigned to the variables.
|
|
|
|
You will also need to account for spaces in your string, so that the final sentence has spaces between all the words. The result should be a complete sentence.
|
|
|
|
# --before-each--
|
|
|
|
```js
|
|
const removeAssignments = str => str
|
|
.replace(/myNoun\s*=\s*["']dog["']/g, '')
|
|
.replace(/myAdjective\s*=\s*["']big["']/g, '')
|
|
.replace(/myVerb\s*=\s*["']ran["']/g, '')
|
|
.replace(/myAdverb\s*=\s*["']quickly["']/g, '');
|
|
```
|
|
|
|
# --hints--
|
|
|
|
`wordBlanks` should be a string.
|
|
|
|
```js
|
|
assert(typeof wordBlanks === 'string');
|
|
```
|
|
|
|
You should not change the values assigned to `myNoun`, `myVerb`, `myAdjective` or `myAdverb`.
|
|
|
|
```js
|
|
assert(
|
|
myNoun === 'dog' &&
|
|
myVerb === 'ran' &&
|
|
myAdjective === 'big' &&
|
|
myAdverb === 'quickly'
|
|
);
|
|
```
|
|
|
|
You should not directly use the values `dog`, `ran`, `big`, or `quickly` to create `wordBlanks`.
|
|
|
|
```js
|
|
const newCode = removeAssignments(__helpers.removeJSComments(code));
|
|
assert(
|
|
!/dog/.test(newCode) &&
|
|
!/ran/.test(newCode) &&
|
|
!/big/.test(newCode) &&
|
|
!/quickly/.test(newCode)
|
|
);
|
|
```
|
|
|
|
`wordBlanks` should contain all of the words assigned to the variables `myNoun`, `myVerb`, `myAdjective` and `myAdverb` separated by non-word characters (and any additional words of your choice).
|
|
|
|
```js
|
|
assert(
|
|
/\bdog\b/.test(wordBlanks) &&
|
|
/\bbig\b/.test(wordBlanks) &&
|
|
/\bran\b/.test(wordBlanks) &&
|
|
/\bquickly\b/.test(wordBlanks)
|
|
);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
const myNoun = "dog";
|
|
const myAdjective = "big";
|
|
const myVerb = "ran";
|
|
const myAdverb = "quickly";
|
|
|
|
// Only change code below this line
|
|
const wordBlanks = ""; // Change this line
|
|
// Only change code above this line
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
const myNoun = "dog";
|
|
const myAdjective = "big";
|
|
const myVerb = "ran";
|
|
const myAdverb = "quickly";
|
|
|
|
let wordBlanks = "Once there was a " + myNoun + " which was very " + myAdjective + ". ";
|
|
wordBlanks += "It " + myVerb + " " + myAdverb + " around the yard.";
|
|
```
|