-
Notifications
You must be signed in to change notification settings - Fork 63
homework_1: homework done #37
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
base: main
Are you sure you want to change the base?
Conversation
src/homeworks/ts1/1_base.ts
Outdated
| export const removeFirstZeros = (value: string) => value.replace(/^(-)?[0]+(-?\d+.*)$/, '$1$2'); | ||
|
|
||
| export const getBeautifulNumber = (value, separator = ' ') => | ||
| export const getBeautifulNumber = (value: string, separator = ' ') => |
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
| export const getNumberedArray = (arr) => arr.map((value, number) => ({ value, number })); | ||
| export const toStringArray = (arr) => arr.map(({ value, number }) => `${value}_${number}`); | ||
| export const getNumberedArray = (arr: Array<number>) => arr.map((value, number) => ({ value, number })); | ||
| export const toStringArray = (arr: { value: string; number: 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.
Там могут быть что-то помимо строки?например number
src/homeworks/ts1/1_base.ts
Outdated
| * Нужно превратить файл в ts и указать типы аргументов и типы возвращаемого значения | ||
| * */ | ||
| export const removePlus = (string) => string.replace(/^\+/, ''); | ||
| export const removePlus = (string: string) => string.replace(/^\+/, ''); |
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
| export const longColorRegExp = /^#[0-9a-f]{6}$/i; | ||
|
|
||
| export const checkColor = (color) => { | ||
| export const checkColor = (color: 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.
Тут интересный ответ получается например
| return [red, green, blue]; | ||
| }; | ||
|
|
||
| export const getNumberedArray = <T>(arr: Array<T>): { value: T; number: number }[] => |
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: T; number: number }[]
| export const getNumberedArray = <T>(arr: Array<T>): { value: T; number: number }[] => | ||
| arr.map((value, number) => ({ value, number })); | ||
|
|
||
| export const toStringArray = (arr: { value: string | number; number: string | number }[]): 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: string | number; number: string | number }[]
No description provided.