-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Answer: 43 #1149
Answer: 43 #1149
Conversation
export class UserComponent { | ||
readonly name = input.required<string>(); | ||
readonly lastName = input<string>(''); | ||
readonly age = input<string>(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add a transform method to make it a number with a default value to 0
this.fullName = `${this.name} ${this.lastName ?? ''}`; | ||
this.category = ageToCategory(Number(this.age) ?? 0); | ||
} | ||
readonly fullName = computed(() => `${this.name()} ${this.lastName() ?? ''}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need the ?? '', lastName has a default value.
10: 'Youth', | ||
18: 'Junior', | ||
35: 'Open', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not putting this const outside of the scope of the function, so you don't recreate it at each call.
nice work |
This pull request is stale because it has been open for 15 days with no activity. |
This pull request was closed because it has been inactive for 5 days since being marked as stale. |
Checklist for challenge submission
Warning:
Alternatively, you can still submit your PR to join the list of answered challenges or to be reviewed by a community member. 🔥