Да прошла задача и без параметра randomized)
7 этап не пускает меня, хотя всё работает, может чего не понял =(
functions.js
import {sleep} from './helper.js'
export const writeLog = async (text, delay, randomized) => {
const splitText = text.split('');
// console.log(randomized);
if (randomized) {
delay = Math.random(0, delay) * delay;
}
for (let i = 0; i < splitText.length; i++) {
process.stdout.write(splitText[i]);
await sleep(delay);
}
// console.log(delay);
process.stdout.write('\n');
}
export const funkylog = (object) => (text) => {
// console.log(object);
writeLog(text, object.delay, object.randomized);
}
solution.js
import {funkylog} from './functions.js';
const message = `
Hello, world 👋!
Let's make our Console Output Fun and Interactive in JavaScript and Node.js 🚀
`;
const log = funkylog({ delay: 100, randomized: true });
log('Hello, world!');
helper.js
export const sleep = (ms) => new Promise((resolve, reject) => {
setTimeout (() => {resolve(ms)},ms)
});