Fix the function startProgressBar
Expected behavior:
- The function should display the progress bar on the screen and move it forward each
delay
ms. - The interval should be cleared once the progress bar is full.
Don’t forget to run npm install
in terminal before starting the task!
This task is part of the Full-Stack JavaScript Course
If you have any issues with it, you can ask for community help below the post
Feel free to help others if you’ve already solved the task
functions.js
export const startProgressBar = (progressBar, delay) => {
const timer = setInterval(() => {
progressBar.tick();
if (progressBar.complete) {
console.log('DONE!');
}
}, 100);
}
solution.js
/**
* Fix the function `startProgressBar`
*
* Expected behavior:
* The function should display the progress bar on the screen and move it forward each `delay` ms.
* The interval should be cleared once the progress bar is full.
*
* */
import { startProgressBar } from './functions.js';
import ProgressBar from 'progress';
const bar = new ProgressBar(':bar :percent', { total: 100 })
startProgressBar(100);