Console in chrome - question

Hi, I am trying to write everything in the google console.
once I have run a let =
I am not able to run it again, is there a trick to run the same program again?

let yourName;
do {
yourName = prompt(“Who are you?”);
} while (!yourName);
console.log(yourName);
VM854:1 Uncaught SyntaxError: Identifier ‘yourName’ has already been declared
at :1:1

thanks

Sure it’s because the variable has already been declared in your scope.
You can call it without let (because let is a declaration).
Or change it’s behavior:

> let hello = "hello"
undefined
> hello
"hello"
> hello = "hello Rob"
"hello Rob"
>hello
"hello Rob"

In you case the remove the line with let yourName

1 Like