vendredi 20 août 2021

For loop nested Pattern in Javascript

I have been trying to get a progress bar representation that looks like this: The user has to enter an input, and as of the input, the loop will run and get to a 100%.

Enter State: 70

[####### ] 70 % [######## ] 80 % [######### ] 90 % [##########] 100 %

Here is what I have ade so far, but I am stuck now:

let hashtag = "";
for (let i = 1; i <= 3; i++) {
  hashtag += "#";
}

console.log(
  "[" + hashtag + " ",
  " ",
  " ",
  " ",
  " ",
  " ",
  " " + "]" + " " + "30%"
);

Any ideas of how to solve this problem? I a a total beginner, please go easy on me" :)

Aucun commentaire:

Enregistrer un commentaire