-
Notifications
You must be signed in to change notification settings - Fork 0
homework1 #1
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
Conversation
src/homeworks/ts1/1_base.ts
Outdated
|
|
||
| export const removeFirstZeros = (value: string): string => value.replace(/^(-)?[0]+(-?\d+.*)$/, '$1$2'); | ||
|
|
||
| export const getBeautifulNumber = (value?: number | null, separator: 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.
Добрый день тут достаточно (value: number separator: string = ' '):string
Мы жестко принимает примитив => приводим к строке и разбиваем как нужно
separator: string = ' ' если мы кладем значение в переменную то тип указывать не нужно так как будет работать утиная типизация
Стоит указать что возвращает ф-ия так при разработке будет меньше ошибок
| const transformRegexp: RegExp = | ||
| /(matrix\(-?\d+(\.\d+)?, -?\d+(\.\d+)?, -?\d+(\.\d+)?, -?\d+(\.\d+)?, )(-?\d+(\.\d+)?), (-?\d+(\.\d+)?)\)/; | ||
|
|
||
| type TransformedRegexp = { |
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.
Прекрасно
| // http://www.w3.org/TR/AERT#color-contrast | ||
| Math.round((red * 299 + green * 587 + blue * 114) / 1000); | ||
|
|
||
| type BlackOrWhite = 'black' | 'white'; |
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.
Отличное решение которое в дальнейшем может сэкономить уйму сил, времени и денег
src/homeworks/ts1/1_base.ts
Outdated
| number: number; | ||
| }; | ||
|
|
||
| export const getNumberedArray = (arr: unknown[]): NumberedArrayItem[] => |
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.
Хорошее решение, еще можно использовать джинерики
No description provided.