fix(curriculum): improve lab password generator last user story (#60360)

Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
This commit is contained in:
Giftea ☕
2025-05-16 18:01:32 +01:00
committed by GitHub
parent 1eda9b1db8
commit 9ac7e5e7c3

View File

@@ -16,7 +16,7 @@ In this lab, you'll practice using functions by building a random password gener
1. You should create a function called `generatePassword` that takes a parameter, indicating the length of generated password. You can name the parameter whatever you like.
2. Your function should return a string which represents a randomly generated password. You should use the following string and different `Math` methods to help you return a new string with random characters in it: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()`.
3. You should define a variable called `password` and assign it the result of calling the `generatePassword` function with a numeric argument that represents the desired password length.
4. You should have a `console.log` that logs the message `"Generated password:"` followed by the `password` variable.
4. You should have a `console.log` that logs a single string made by concatenating the message `Generated password:` and the `password` variable separated by a space.
# --hints--
@@ -85,11 +85,12 @@ assert.equal(password3.length, generatePassword(length2).length);
assert.match(__helpers.removeJSComments(code), /(let|const)\s+password\s*=\s*generatePassword\(\d+\)\;/);
```
You should log the generated password to the console.
You should log a single string combining `Generated password:` and the `password` separated by a single space using `+` or a template literal.
```js
const condition1 = /console\.log\(\s*["']Generated\s+password:\s*["']\s*\+\s*password\s*\);?/gm.test(code);
const condition2 = /console\.log\(\s*`Generated\s+password:\s*\$\{password\}`\s*\);?/gm.test(code);
const cleanCode = __helpers.removeJSComments(code);
const condition1 = /console\.log\(\s*["']Generated\s+password:\s*["']\s*\+\s*password\s*\);?/gm.test(cleanCode);
const condition2 = /console\.log\(\s*`Generated\s+password:\s*\$\{password\}`\s*\);?/gm.test(cleanCode);
assert.isTrue(condition1 || condition2);
```