fix(curriculum): allow variables in lab trivia bot (#57782)

Co-authored-by: Naomi <accounts+github@nhcarrigan.com>
This commit is contained in:
Anna
2025-01-02 09:49:56 +01:00
committed by GitHub
co-authored by Naomi
parent 59fcfae9ad
commit 79f6622403
@@ -72,20 +72,18 @@ You should use `let` to declare a new variable `codingFact`.
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|').+?\2\s*\+\s*favoriteLanguage/g)
assert.match(code, /let\s+codingFact/)
assert.include(first, 'let');
assert.exists(first);
```
You should give `codingFact` a value that includes `favoriteLanguage` using concatenation.
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|').+?\2\s*\+\s*favoriteLanguage/g)
assert.match(code, /let\scodingFact\s*=\s*("|').+?\1\s*\+\s*favoriteLanguage/)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|')?.+?\2?\s*\+\s*favoriteLanguage/g)
assert.match(code, /let\scodingFact\s*=\s*("|')?.+?\1?\s*\+\s*favoriteLanguage/)
assert.include(first, 'let');
assert.exists(first);
assert.isNotEmpty(codingFact);
```
You should log `codingFact` to the console.
@@ -102,11 +100,12 @@ You should assign a new value to `codingFact` that also contains `favoriteLangua
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const loggingCodingFacts = codeWithoutComments.match(/console\.log\(\s*codingFact\s*\)/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|').+?\2\s*\+\s*favoriteLanguage/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|')?.+?\2?\s*\+\s*favoriteLanguage/g)
assert.include(output[4], favoriteLanguage);
assert.notEqual(output[4], output[3]);
assert.isAtLeast(loggingCodingFacts.length, 2);
assert.exists(second);
assert.isNotEmpty(codingFact);
```
You should assign a value to `codingFact` for the third time that also contains `favoriteLanguage`, and log it to the console.
@@ -114,12 +113,13 @@ You should assign a value to `codingFact` for the third time that also contains
```js
const codeWithoutComments = __helpers.removeJSComments(code);
const loggingCodingFacts = codeWithoutComments.match(/console\.log\(\s*codingFact\s*\)/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|').+?\2\s*\+\s*favoriteLanguage/g)
const [first, second, third] = codeWithoutComments.match(/(let )?\s*codingFact\s*=\s*("|')?.+?\2?\s*\+\s*favoriteLanguage/g)
assert.include(output[5], favoriteLanguage);
assert.notEqual(output[5], output[4]);
assert.equal(output[5], codingFact);
assert.lengthOf(loggingCodingFacts, 3);
assert.exists(third);
assert.isNotEmpty(codingFact);
```
You should log to the console `"It was fun sharing these facts with you. Goodbye! - (botName) from (botLocation)."` using concatenation to add the values of the variables.