Created
June 19, 2022 09:05
-
-
Save ihopeudie/1fb524cc9ed1da65cb40eccb3078a57d to your computer and use it in GitHub Desktop.
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
const months = { | |
ru: ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'], | |
en: ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] | |
} | |
function askMonth() { | |
let language = prompt('Введите ru или en'); | |
if (language !== 'ru' && language !== 'en') { | |
console.error("Неверный язык"); | |
return; | |
} | |
let month = prompt('введите номер месяца, который хотите вывести'); | |
if (!month || isNaN(month) || parseInt(month) < 1 || parseInt(month) > 12) { | |
console.error("Неверный месяц"); | |
return; | |
} | |
alert(months[language][month-1]); | |
} | |
askMonth(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment