TZinovieva

Loading Bar

Feb 4th, 2023 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function loadingBar(n) {
  2.     let result = 0;
  3.         if (n % 10 === 0) {
  4.             result = n * 10;
  5.         }
  6.         let percentage = '%'.repeat(n / 10);
  7.         let dots = '.'.repeat(10 - n / 10);
  8.        
  9.     console.log(`${n}% [${percentage}${dots}]`);
  10.     console.log("Still loading...");
  11.  
  12.     if (n === 100) {
  13.         console.log("100% Complete!");
  14.         console.log(`[${percentage}]`);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment