Nonsense Logs
const SPEED = 700;
const addKeys = obj => {
obj.keys = Object.keys(obj)
return obj
}
const wordParts = {
start: addKeys({
z: .3,
zim: .1,
zz: .1,
zzz: .1,
ziz: .05,
zoo: .1,
koe: .05,
kob: .05,
'cow cow': .1,
'how ': .02,
sl: .1,
ko: .05
}),
mid: addKeys({
i: .1,
oo: .1,
a: .1,
e: .3,
oe: .1,
ebobe: .1,
y: .1
}),
end: addKeys({
z: .3,
n: .1,
t: .05,
rat: .1,
'!': .05,
'?': .05,
'': .1
})
};
const wordPart = (
type,
dupeOdds = .1,
dupeMax = 8,
capOdds = .05
) => {
let result = '';
const part = wordParts[type];
while (result === '') {
const choice = part.keys[
Math.floor(Math.random() * part.keys.length)
];
if (Math.random() < part[choice]) {
result = choice;
if (Math.random() < dupeOdds) {
const dupes = Math.round(
Math.random() * Math.random() * dupeMax
);
result = result.repeat(dupes);
}
}
}
wordPart.accum += result;
if (Math.random() < capOdds) {
wordPart.accum = wordPart.accum.toUpperCase()
}
return wordPart;
}
wordPart.accum = '';
const word = () =>
wordPart('start')('mid')('end').accum + ' '
document.body.style.fontSize="2em";
setInterval(() => {
document.body.innerHTML += word();
wordPart.accum = ''
}, SPEED);
Sometimes to entertain myself I will write nonsense style print/log statements. Things like console.log('cowcow')
. This snippet generates a variety of these kinds of phrases.