//Create a function that returns a string, of a given length
const genRand = (len) => {
return Math.random().toString(36).substring(2,len+2);
}
console.log(genRand(8));
//Expected output example: 4yg020wn
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var result = ""
var chaactersLength = characters.length;
for ( var i = 0; i < 5 ; i++ ) {
result += characters.charAt(Math.floor(Math.random() * chaactersLength));
}
console.log(result)
function randomString(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+=-';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
randomString(4);
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() *
charactersLength));
}
return result;
}
console.log(makeid(5));
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
function generateRandomCode(){
let result = ""
let charactersLength = characters.length;
for ( var i = 0; i < 6 ; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result
}
function random_string(strLen=8) {
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var result = ""
var charactersLength = characters.length;
for (var i = 0; i < strLen; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
it('should add random string into input field ', async () => {
const characters ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
function generateString(length) {
let result = ' ';
const charactersLength = characters.length;
for ( let i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
let input = await $('#email')
await input.addValue(generateString(5))
await browser.pause(4000);
})