Skip to content
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

solution #247

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

solution #247

wants to merge 3 commits into from

Conversation

coroboX
Copy link

@coroboX coroboX commented May 26, 2020

No description provided.

src/getTime.js Outdated
@@ -18,7 +18,25 @@
* @returns {string} - valid time
*/
function getTime(str) {
// write code here
const hhmm = str.match(/\b\d{2}:\d{2}\b/);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Твій regex метчить "неправильний" час, як то 24:50. Можна написати регулярний вираз так, щоб такі випадки не включались.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переускладнювати код регулярки не хочу, щоб зберегти читабельність.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну дивись)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const hhmm = str.match(/\b\d{2}:\d{2}\b/);
const matches = str.match(/\b\d{2}:\d{2}\b/);

src/getTime.js Outdated
@@ -18,7 +18,25 @@
* @returns {string} - valid time
*/
function getTime(str) {
// write code here
const hhmm = str.match(/\b\d{2}:\d{2}\b/);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const hhmm = str.match(/\b\d{2}:\d{2}\b/);
const matches = str.match(/\b\d{2}:\d{2}\b/);

src/getTime.js Outdated
Comment on lines 23 to 39
if (!hhmm) {
return '';
}

const hh = hhmm[0].substr(0, 2);
const mm = hhmm[0].substr(3, 2);
let time = '';

if (+hh > 23) {
time = '';
} else if (+mm > 59) {
time = '';
} else {
time = hh + ':' + mm;
}

return time;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этого не должно быть, мы работаем с регулярными выражениями

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants