Errors 10 exercises

Fixing "Cannot Redeclare Block-Scoped Variable"

This exercise includes an actual folder.

Inside of index.js we have a single line of code that declares a const name variable:

const name = "Matt"; // red squiggly line under name
// Hovering over `name` shows:
Cannot re-declare block-scoped variable 'name'.

Loading exercise


00:00 In this exercise, we have a const name here and we're getting an error saying cannot re-declare block scoped variable name. What? This seems really, really weird. Your job is to work out why this error is occurring.

00:16 And I've given you an actual folder to work in here because the change, there is a change that you can make inside this file, which won't affect things too much, but there is also a change you can make in tsconfig.json, there's an option you can add to this. I will give you a link below to this so you can actually figure this out because there's a lot of potential options in here.

00:35 Oh my God. So I prefer the tsconfig change, but if you can find the actual change you can make inside index.ts, that's pretty cool too. So see if you can work out why this error is occurring and yeah, I'll see you on the other side.