Skip to content

Instantly share code, notes, and snippets.

@ihopeudie
Created June 19, 2022 09:05
Show Gist options
  • Save ihopeudie/1fb524cc9ed1da65cb40eccb3078a57d to your computer and use it in GitHub Desktop.
Save ihopeudie/1fb524cc9ed1da65cb40eccb3078a57d to your computer and use it in GitHub Desktop.
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