-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Организация кода + Функции возвращаются 'Делу — время'
- Loading branch information
Showing
10 changed files
with
73 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const checkStringLength = (string = '', maxSymbols = 1) => string.length <= maxSymbols; | ||
checkStringLength('проверяемая строка', 20); | ||
|
||
const testPolyndrome = (string = '') => { | ||
string = string.replaceAll(' ', '').toLowerCase(); | ||
let reversal = ''; | ||
|
||
for (let i = string.length - 1; i >= 0; i--) { | ||
reversal += string[1]; | ||
} | ||
return string === reversal; | ||
}; | ||
testPolyndrome('Лёша на полке клопа нашёл '); | ||
|
||
const extractNumber = (string) => { | ||
let result = ''; | ||
|
||
string = string.toString(); | ||
|
||
for (let i = 0; i <= string.length; i++) { | ||
if (Number.isNaN(parseInt(string[i], 10)) === false) { | ||
result += string[i]; | ||
} | ||
} | ||
return result === '' ? NaN : Number(result); | ||
}; | ||
extractNumber('извлекает содержащиеся в ней цифры от 0 до 9'); | ||
|
||
const checkMeetingTime = (startDayTime, endDayTime, startmeetingTime, duration) => { | ||
|
||
function countMinutes(time) { | ||
const [hours, minutes] = time.split(':'); | ||
return hours * 60 + parseInt(minutes, 10); | ||
} | ||
|
||
const startDayminutes = countMinutes(startDayTime); | ||
const endDayMinutes = countMinutes(endDayTime); | ||
const startMeetingminutes = countMinutes(startmeetingTime); | ||
const endMeetingMinutes = startMeetingminutes + duration; | ||
|
||
return startDayminutes <= startMeetingminutes && endMeetingMinutes <= endDayMinutes; | ||
}; | ||
|
||
checkMeetingTime('08:00', '17:30', '14:00', 90); | ||
checkMeetingTime('8:0', '10:0', '8:0', 120); | ||
checkMeetingTime('08:00', '14:30', '14:00', 90); | ||
checkMeetingTime('14:00', '17:30', '08:0', 90); | ||
checkMeetingTime('8:00', '17:30', '08:00', 900); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
import { | ||
generatedObjectArrays | ||
} from './generated-object'; | ||
import { | ||
checkStringLength | ||
} from './check-string-length'; | ||
import { | ||
extractNumber | ||
} from './extract-number'; | ||
import { | ||
testPolyndrome | ||
} from './test-polyndrome'; | ||
|
||
} from './utils/generated-object'; | ||
|
||
checkStringLength('проверяемая строка', 20); | ||
extractNumber('извлекает содержащиеся в ней цифры от 0 до 9'); | ||
testPolyndrome('Лёша на полке клопа нашёл '); | ||
generatedObjectArrays(); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.