З🧟
Size: a a a
З🧟
SM
РР
НА
R
CM
ИК
НА
ИК
L
function getRandomLetter() {
return String.fromCharCode((Math.random() * 25 + 97) ^ 0);
}
function getRandomLetters() {
return getRandomLetter() + getRandomLetter() + getRandomLetter() + getRandomLetter()
}
let tmp = {}
const I = 25
function addProps (index = 0, o = {}) {
if (index < I) {
const l1 = getRandomLetters()
o[l1] = {}
o[l1] = addProps(index + 1, o[l1])
const l2 = getRandomLetters()
o[l2] = {}
o[l2] = addProps(index + 1, o[l2])
return o
}
return true
}
console.time(I)
tmp = addProps(0, tmp)
console.timeEnd(I)
function makeString(o, p = '') {
if (typeof o === 'boolean') {
return p
}
const key = Object.keys(o)[Math.round(Math.random())]
return makeString(o[key], p + key)
}
console.time('toStr')
const res = makeString(tmp)
console.timeEnd('toStr')
console.log(res)
console.log(res.length)