Let’s start this by giving a BIG CHEER FOR JavaScript!
Give me a J → J
Give me a a → a
Give me a v → v
Give me a a → a
Give me a S → S
Give me a c → c
Give me a r → r
Give me a i → i
Give me a p → p
Give me a t → t
My Fifth Attempt ( 1st advance code that I wrote by my own with some help in other coder’s codes )
Getting the Sundays as dates of a month!
1st One :
Get the Sundays as dates of the current month with commas!
JS Code
var d= new Date();
var dd= d.setMonth(d.getMonth() , 2 );
var dd = d.toISOString().slice(0, 10);
var year = d.getFullYear();
var month = d.getMonth() + 1;
var d= new Date(year,month,0);
var n = d.getDate();
var d = new Date(dd);
var Sunday = new Date(dd);
Sunday.setDate(d.getDate() - (d.getDay()||7) +7);
var get_sunday_date = Sunday.getDate();
var a = (Sunday.getDate());
var b = (Sunday.getDate() + 7);
var c = (Sunday.getDate() + 7 + 7);
var d = (Sunday.getDate() + 7 + 7 + 7);
var e = (Sunday.getDate() + 7 + 7 + 7 + 7);
var get_sunday_month = Sunday.getMonth() + 1;
if (get_sunday_month < 10) {
var get_sunday_month = "0" + (Sunday.getMonth() + 1);
} else {
var get_sunday_month = Sunday.getMonth() + 1;
}
var get_sunday_year = Sunday.getFullYear();
if (a < 10) {
var a = "0" + a;
}
if (b < 10) {
var b = "0" + b;
}
var a = get_sunday_year + "-" + get_sunday_month + "-" + a;
var b = get_sunday_year + "-" + get_sunday_month + "-" + b;
var c = get_sunday_year + "-" + get_sunday_month + "-" + c;
var d = get_sunday_year + "-" + get_sunday_month + "-" + d;
var e = get_sunday_year + "-" + get_sunday_month + "-" + e;
var f = (Sunday.getDate() + 7 + 7 + 7 + 7)
if (f > n) {
var all = a + "," + b + "," + c + "," + d;
} else {
var all = a + "," + b + "," + c + "," + d + "," + e;
}
return all
Preview
2nd One :
Get the Sundays as dates of the current month with spaces!
JS Code
var d= new Date();
var dd= d.setMonth(d.getMonth() , 2 );
var dd = d.toISOString().slice(0, 10);
var year = d.getFullYear();
var month = d.getMonth() + 1;
var d= new Date(year,month,0);
var n = d.getDate();
var d = new Date(dd);
var Sunday = new Date(dd);
Sunday.setDate(d.getDate() - (d.getDay()||7) +7);
var get_sunday_date = Sunday.getDate();
var a = (Sunday.getDate());
var b = (Sunday.getDate() + 7);
var c = (Sunday.getDate() + 7 + 7);
var d = (Sunday.getDate() + 7 + 7 + 7);
var e = (Sunday.getDate() + 7 + 7 + 7 + 7);
var get_sunday_month = Sunday.getMonth() + 1;
if (get_sunday_month < 10) {
var get_sunday_month = "0" + (Sunday.getMonth() + 1);
} else {
var get_sunday_month = Sunday.getMonth() + 1;
}
var get_sunday_year = Sunday.getFullYear();
if (a < 10) {
var a = "0" + a;
}
if (b < 10) {
var b = "0" + b;
}
var a = get_sunday_year + "-" + get_sunday_month + "-" + a;
var b = get_sunday_year + "-" + get_sunday_month + "-" + b;
var c = get_sunday_year + "-" + get_sunday_month + "-" + c;
var d = get_sunday_year + "-" + get_sunday_month + "-" + d;
var e = get_sunday_year + "-" + get_sunday_month + "-" + e;
var f = (Sunday.getDate() + 7 + 7 + 7 + 7)
if (f > n) {
var all = a + "\n\n" + b + "\n\n" + c + "\n\n" + d;
} else {
var all = a + "\n\n" + b + "\n\n" + c + "\n\n" + d + "\n\n" + e;
}
return all
Preview
3rd One :
Get the Sundays of the selected date’s month with commas!
JS Code
Same but connect the date column to the JavaScript column with p1! So need to select the Date column for p1 and add p1 in the start of the code inside newDate() brackets!
var d= new Date(p1);
var dd= d.setMonth(d.getMonth() , 2 );
var dd = d.toISOString().slice(0, 10);
var year = d.getFullYear();
var month = d.getMonth() + 1;
var d= new Date(year,month,0);
var n = d.getDate();
var d = new Date(dd);
var Sunday = new Date(dd);
Sunday.setDate(d.getDate() - (d.getDay()||7) +7);
var get_sunday_date = Sunday.getDate();
var a = (Sunday.getDate());
var b = (Sunday.getDate() + 7);
var c = (Sunday.getDate() + 7 + 7);
var d = (Sunday.getDate() + 7 + 7 + 7);
var e = (Sunday.getDate() + 7 + 7 + 7 + 7);
var get_sunday_month = Sunday.getMonth() + 1;
if (get_sunday_month < 10) {
var get_sunday_month = "0" + (Sunday.getMonth() + 1);
} else {
var get_sunday_month = Sunday.getMonth() + 1;
}
var get_sunday_year = Sunday.getFullYear();
if (a < 10) {
var a = "0" + a;
}
if (b < 10) {
var b = "0" + b;
}
var a = get_sunday_year + "-" + get_sunday_month + "-" + a;
var b = get_sunday_year + "-" + get_sunday_month + "-" + b;
var c = get_sunday_year + "-" + get_sunday_month + "-" + c;
var d = get_sunday_year + "-" + get_sunday_month + "-" + d;
var e = get_sunday_year + "-" + get_sunday_month + "-" + e;
var f = (Sunday.getDate() + 7 + 7 + 7 + 7)
if (f > n) {
var all = a + "," + b + "," + c + "," + d;
} else {
var all = a + "," + b + "," + c + "," + d + "," + e;
}
return all
Preview
4th One :
Get the Sundays of the selected date’s month with spaces!
JS Code
Same but connect the date column to the JavaScript column with p1! So need to select the Date column for p1 and add p1 in the start of the code inside newDate() brackets!
var d= new Date(p1);
var dd= d.setMonth(d.getMonth() , 2 );
var dd = d.toISOString().slice(0, 10);
var year = d.getFullYear();
var month = d.getMonth() + 1;
var d= new Date(year,month,0);
var n = d.getDate();
var d = new Date(dd);
var Sunday = new Date(dd);
Sunday.setDate(d.getDate() - (d.getDay()||7) +7);
var get_sunday_date = Sunday.getDate();
var a = (Sunday.getDate());
var b = (Sunday.getDate() + 7);
var c = (Sunday.getDate() + 7 + 7);
var d = (Sunday.getDate() + 7 + 7 + 7);
var e = (Sunday.getDate() + 7 + 7 + 7 + 7);
var get_sunday_month = Sunday.getMonth() + 1;
if (get_sunday_month < 10) {
var get_sunday_month = "0" + (Sunday.getMonth() + 1);
} else {
var get_sunday_month = Sunday.getMonth() + 1;
}
var get_sunday_year = Sunday.getFullYear();
if (a < 10) {
var a = "0" + a;
}
if (b < 10) {
var b = "0" + b;
}
var a = get_sunday_year + "-" + get_sunday_month + "-" + a;
var b = get_sunday_year + "-" + get_sunday_month + "-" + b;
var c = get_sunday_year + "-" + get_sunday_month + "-" + c;
var d = get_sunday_year + "-" + get_sunday_month + "-" + d;
var e = get_sunday_year + "-" + get_sunday_month + "-" + e;
var f = (Sunday.getDate() + 7 + 7 + 7 + 7)
if (f > n) {
var all = a + "\n\n" + b + "\n\n" + c + "\n\n" + d;
} else {
var all = a + "\n\n" + b + "\n\n" + c + "\n\n" + d + "\n\n" + e;
}
return all
Preview
A Video to show the preview of 3rd and 4th one's
Get the Sundays of the selected date's month - Preview.mp4 - Google Drive
Hope to write more advance codes like these in future!
As always, JavaScript Gurus let me know if I have done something wrong or modifies!
Lastly let’s give a Huge Clap for JavaScript & Glide!
Thank you and Have a great day!