Skip to content

Commit

Permalink
Merge pull request #6 from harl-i/module5-task2
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Dec 9, 2024
2 parents 198d0c9 + e51158b commit 9d720aa
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
//Задача №1. Функция для проверки длины строки.
function checkStringLength(string, maxLength) {
return string.length <= maxLength;
}
//5.16. Функции возвращаются

//Задача №2. Функция для проверки, является ли строка палиндромом.
function checkPalindrome(string) {
const formattedString = string.replaceAll(' ', '').toLowerCase();
function checkMeetingTimeframe (startWorkingDay, endWorkingDay, beginningMeeting, durationMeeting) {
const startWorkingDayInMinutes = convertToMinutes(startWorkingDay);
const endWorkingDayInMinutes = convertToMinutes(endWorkingDay);
const beginningMeetingInMinutes = convertToMinutes(beginningMeeting);

let reverseString = '';
for (let i = formattedString.length - 1; i >= 0; i--) {
reverseString += formattedString[i];
}
return reverseString === formattedString;
}
const isMeetingAfterWorkStart = startWorkingDayInMinutes <= beginningMeetingInMinutes;
const isMeetingBeforeWorkEnd = (beginningMeetingInMinutes + durationMeeting) <= endWorkingDayInMinutes;

//Задача №3. Извлечение цифр из строк.
function parseToPositiveInt(string) {
const stringForloop = string.toString();
return isMeetingAfterWorkStart && isMeetingBeforeWorkEnd;
}

let formattedString = '';
for (let i = 0; i < stringForloop.length; i++) {
if (!isNaN(parseInt(stringForloop[i], 10))) {
formattedString += stringForloop[i];
}
}
function convertToMinutes(inputValue) {
const [hours, minutes] = inputValue.split(':');

return formattedString !== '' ? +formattedString : NaN;
return (Number(hours) * 60) + Number(minutes);
}

console.log(checkMeetingTimeframe('08:00', '17:30', '14:00', 90));

Check failure on line 20 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(checkMeetingTimeframe('8:0', '10:0', '8:0', 120));

Check failure on line 21 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(checkMeetingTimeframe('08:00', '14:30', '14:00', 90));

Check failure on line 22 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(checkMeetingTimeframe('14:00', '17:30', '08:0', 90));

Check failure on line 23 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(checkMeetingTimeframe('8:00', '17:30', '08:00', 900));

Check failure on line 24 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement

Check failure on line 24 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Newline required at end of file but not found

0 comments on commit 9d720aa

Please sign in to comment.