Errors 10 exercises
Problem

Fixing "Property X Has No Initializer"

In this exercise, we're working with a User class that contains a private property named username:


class User {
private username: string; // red squiggly line under username
}

There is an error under username that reads:


// hovering over username shows:
Prop

Loading exercise

Transcript

00:00 In this exercise we have a class of user where it has a private property of username and username is saying property username has no initializer and is not definitely assigned in the constructor. Your job is to work out why this error is occurring and how we can make it go away. Good luck!