<h1>Пробное занятие запланировано на 18 февраля 19:00.</h1>
JavaScript
/*
Пробное занятие запланировано на 18 февраля 19:00. После того, как наступило 18 февраля 19:00, дата должна смениться на 20 февраля 19:00. Аналогично с 20 на 25 февраля. На этом цикл завершился.
И так должно продолжаться и дальше, т.к. 2 занятия в неделю в школе танцев
*/
let nextSchedule = document.querySelector('h1');
let now = new Date();
let months = ["января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"];
const monday = 1;
const wednesday = 3;
const nextMonday = 5;
const nextWednesday = 2;
let nextMondayDay = now.getDate() + nextMonday;
let nextWednesdayDay = now.getDate() + nextWednesday;
let nextMonth = new Date(now);
if (now.getDay() === monday) {
nextMonth.setDate(now.getDate() + nextWednesday);
nextSchedule.innerHTML = `Пробное занятие запланировано на ${nextWednesdayDay} ${months[nextMonth.getMonth()]} 19:00.`;
} else if (now.getDay() === wednesday) {
nextMonth.setDate(now.getDate() + nextMonday);
nextSchedule.innerHTML = `Пробное занятие запланировано на ${nextMondayDay} ${months[nextMonth.getMonth()]} 19:00.`;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.