Complete the code to generate a random email for testing.
const randomEmail = `user$[1]@example.com`;Using Math.random().toString(36).substring(2, 10) generates a random string suitable for unique emails.
Complete the code to create a random username with a prefix.
const username = `user_$[1]`;Math.floor(Math.random() * 10000) generates a random integer between 0 and 9999, good for usernames.
Fix the error in the code to generate a random password of length 8.
const password = Array.from({ length: 8 }, () => [1]).join('');
Using charAt(2) gets a valid character from the random string. charAt(0) is '0', and higher indexes may be undefined.
Fill both blanks to create a dynamic test user object with random id and email.
const testUser = { id: [1], email: `test$[2]@mail.com` };Use Math.floor(Math.random() * 1000) for a random id number and Math.random().toString(36).substring(2, 8) for a random email string.
Fill all three blanks to generate a dynamic test data object with username, password, and email.
const testData = { username: `user$[1]`, password: Array.from({ length: 6 }, () => [2]).join(''), email: `email$[3]@test.com` };Use Date.now() for username suffix for uniqueness, charAt(2) for password characters, and substring(2, 6) for email random part.