Oddbean new post about | logout
โ–ฒ โ–ผ
 /run javascript
// ๐Ÿฆ™ใจ๐ŸŒˆ๐Ÿฆ™ใฎใƒชใ‚นใƒˆ
const llamas = ['๐Ÿฆ™', '๐ŸŒˆ๐Ÿฆ™'];

// ใƒฉใƒณใƒ€ใƒ ใชๆ•ดๆ•ฐใ‚’็”Ÿๆˆใ™ใ‚‹้–ขๆ•ฐ
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

// ใƒฉใƒณใƒ€ใƒ ใช๐Ÿฆ™ใ‚’้ธๆŠžใ™ใ‚‹้–ขๆ•ฐ
function getRandomLlama() {
const randomIndex = Math.floor(Math.random() * llamas.length);
return llamas[randomIndex];
}

// ใƒฉใƒณใƒ€ใƒ ใชๅ›žๆ•ฐใ ใ‘๐Ÿฆ™ใ‚’็”Ÿๆˆใ—ใ€ๆ–‡ๅญ—ๅˆ—ใจใ—ใฆใพใจใ‚ใ‚‹้–ขๆ•ฐ
function generateLlamasString() {
const count = getRandomInt(1, 5);
let result = 'ใ†ใซใ‚…ใ†ใ€';
for (let i = 0; i < count; i++) {
result += getRandomLlama();
}
return result;
}

// ๐Ÿฆ™ใ‚’่กจ็คบใ™ใ‚‹
console.log(generateLlamasString());