Loop JavaScript

Hi, I am stuck in here for hours, can anybody enlight me , with some directions ?

the challenge is:

You know that your target’s password is 4 characters long, so you’ll just have to brute force 1 character at a time. We already declared the variable correctGuesses which you should use to keep track of how many characters you have guessed so far.

Bear in mind that your program does not need to guess the password, that is not your goal!

You need to create a loop that only stops when all 4 characters have been guessed. On each loop iteration you need to calculate a random number between 1 and 3, which will correspond to each of the bellow scenarios:

  1. You guessed one character correctly, which increases correctGuesses by 1 and prints the message ‘Found X characters’ (where X is replaced with the current number of correct guesses).
  2. You guessed incorrectly and your target’s terminal has detected too many attempts, which resets correctGuesses to 0 and prints the message ‘Starting over’ to the console.
  3. You guessed incorrectly, but have not been detected yet, correctGuesses is kept with the same value.

Once the password is cracked (that is, correctGuesses has a value of 4) you should print the message ‘Terminal hacked!’.

Make sure all the messages in your code are in the correct format in order to advance!

// my code:

Captura de ecrã 2022-06-27, às 18.19.44

I have this msg error:

Code is incorrect

You guessed some characters correctly, but failed to do the right thing!

It’s really hard to help using picture of code. Instead, you need to paste all of you JS in here. To display your code in here you need to wrap it in triple back ticks. On a line by itself type three back ticks. Then on the first line below the three back ticks paste in your code. Then below your code on a new line type three more back ticks. The back tick on my keyboard is in the upper left just above the Tab key and below the Esc key.

Also, please provide a link to the instructions for this challenge if available.

Hi, it s challenge in the recruitment process for a bootcamp.
I can’t copy the lines of code, sorry.

It might be an indication that you aren’t ready for this camp.

Does the acessment say that you can ask for help?

I think u should use continue statment in the else if(outcome===3) part
I’m not sure about but u can try it once bcz I think correctGuesses is not getting incremented or something like that.

and i think you should keep that last if statement inside while loop and add a break statement in it otherwise it will only get executed after coming out of while.
and if you do this you’ll have to make while loop like
keeping it’s condition to correctGuesses<=4

I think I have try, can you give a exemple, just to see if I doing fine?
Thanks!

Writing an entry assessment for another user is not really ok. I had to remove your post.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.