Progress Bar Idea
NodeJS
Hard
3 views
Problem Description
Print a simple progress bar from 0 to 100 in steps.
Output Format
Print multiple lines.
Constraints
Use carriage return \\r.
Official Solution
let p = 0;
const id = setInterval(() => {
const bar = '#'.repeat(Math.floor(p / 10)).padEnd(10, '-');
process.stdout.write('\
[' + bar + '] ' + p + '% meetcode');
p += 10;
if (p > 100) {
clearInterval(id);
process.stdout.write('\
');
}
}, 30);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!