I defined a variable and assigned it a function which had syntax error. It throws error. Now, I am unable to use that variable for anything, it always say 'Thrown: ReferenceError: variable is not defined'

> let bg = 'asasas-123d'
undefined
> let fd = bg.substring(indexOf('-')+1)
Thrown:
ReferenceError: indexOf is not defined
> let fd = bg.substring(bg.indexOf('-')+1)
Thrown:
SyntaxError: Identifier 'fd' has already been declared
>  fd = bg.substring(bg.indexOf('-')+1)
Thrown:
ReferenceError: fd is not defined
> let  fd = bg.substring(bg.indexOf('-')+1)
Thrown:
SyntaxError: Identifier 'fd' has already been declared
> fd = bg.substring(bg.indexOf('-')+1)
Thrown:
ReferenceError: fd is not defined
> fd
Thrown:
ReferenceError: fd is not defined
> console.log(fd);
Thrown:
ReferenceError: fd is not defined

1 Answers

0
Jack Bashford On

Just restart your terminal and run this:

> let bg = 'asasas-123d'
> let fd = bg.substring(bg.indexOf("-") + 1))