Simple calendar javascript
I would like to write all the dates, days and months of 2019 in JavaScript. By using 3 functions. I only found 1 function I could use but I don't get it to work out. Anyone have some ideas or tips? Thanks. PS. I am sorry if I posted this wrong or made some misstakes.
EDIT: I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations.
document.writeln("Days in 2019 is:");
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
for (var i = 0; i<=months.length; i++)
{
for (var k = 1; k<=31; k++)
{
document.write(months[i]);
document.writeln(k);
}
}
function rightAdjust(x, size)
{
x = "" + x; // secure that x is a string
var noOfBlanks = size - x.length;
var blanks = "";
for (var i = 0; i < noOfBlanks; i++)
{
blanks = blanks + " ";
}
return blanks + x;
}
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var days;
days = DaysInAMonth(k);
for (var i = 0; i<=months.length; i++){
for (var k = 1; k<=days.length; k++)
{
document.write(months[i]);
document.writeln(days);
}
}
function DaysInAMonth(days)
{
var result;
if (months == [0])
{
return 31;
}
else if (months == [1])
{
return 28;
}
else if (months == [2])
{
return 31;
}
else if (months == [3])
{
return 30;
}
else if (months == [4])
{
return 31;
}
else if (months == [5])
{
return 30;
}
else if (months == [6])
{
return 31;
}
else if (months == [7])
{
return 31;
}
else if (months == [8])
{
return 30;
}
else if (months == [9])
{
return 31;
}
else if (months == [10])
{
return 30;
}
else if (months == [11])
{
return 31;
}
}
document.write(DaysInAMonth(1));
javascript
New contributor
|
show 2 more comments
I would like to write all the dates, days and months of 2019 in JavaScript. By using 3 functions. I only found 1 function I could use but I don't get it to work out. Anyone have some ideas or tips? Thanks. PS. I am sorry if I posted this wrong or made some misstakes.
EDIT: I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations.
document.writeln("Days in 2019 is:");
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
for (var i = 0; i<=months.length; i++)
{
for (var k = 1; k<=31; k++)
{
document.write(months[i]);
document.writeln(k);
}
}
function rightAdjust(x, size)
{
x = "" + x; // secure that x is a string
var noOfBlanks = size - x.length;
var blanks = "";
for (var i = 0; i < noOfBlanks; i++)
{
blanks = blanks + " ";
}
return blanks + x;
}
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var days;
days = DaysInAMonth(k);
for (var i = 0; i<=months.length; i++){
for (var k = 1; k<=days.length; k++)
{
document.write(months[i]);
document.writeln(days);
}
}
function DaysInAMonth(days)
{
var result;
if (months == [0])
{
return 31;
}
else if (months == [1])
{
return 28;
}
else if (months == [2])
{
return 31;
}
else if (months == [3])
{
return 30;
}
else if (months == [4])
{
return 31;
}
else if (months == [5])
{
return 30;
}
else if (months == [6])
{
return 31;
}
else if (months == [7])
{
return 31;
}
else if (months == [8])
{
return 30;
}
else if (months == [9])
{
return 31;
}
else if (months == [10])
{
return 30;
}
else if (months == [11])
{
return 31;
}
}
document.write(DaysInAMonth(1));
javascript
New contributor
"By using 3 functions.": is that a requirement? What exactly are your requirements?
– trincot
1 hour ago
Yes that's a requirement. I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations
– SlipsknuteN
59 mins ago
I'd check your main loop, it's printing beyond December for a month and there seems to be an unidentified function around the line that reads: ' code document.writeln(days); ` I was able to see this on js.do That and some minor formatting, but that's the easy part!
– KoshVorlon
47 mins ago
Hey! Yeah, I removed months.length and wrote there 11 instead so I got unidentified. Thanks for tips though!
– SlipsknuteN
38 mins ago
The problem is that I want to get the array to work instead of at the end. then this whole must enter the "for-preset"
– SlipsknuteN
36 mins ago
|
show 2 more comments
I would like to write all the dates, days and months of 2019 in JavaScript. By using 3 functions. I only found 1 function I could use but I don't get it to work out. Anyone have some ideas or tips? Thanks. PS. I am sorry if I posted this wrong or made some misstakes.
EDIT: I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations.
document.writeln("Days in 2019 is:");
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
for (var i = 0; i<=months.length; i++)
{
for (var k = 1; k<=31; k++)
{
document.write(months[i]);
document.writeln(k);
}
}
function rightAdjust(x, size)
{
x = "" + x; // secure that x is a string
var noOfBlanks = size - x.length;
var blanks = "";
for (var i = 0; i < noOfBlanks; i++)
{
blanks = blanks + " ";
}
return blanks + x;
}
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var days;
days = DaysInAMonth(k);
for (var i = 0; i<=months.length; i++){
for (var k = 1; k<=days.length; k++)
{
document.write(months[i]);
document.writeln(days);
}
}
function DaysInAMonth(days)
{
var result;
if (months == [0])
{
return 31;
}
else if (months == [1])
{
return 28;
}
else if (months == [2])
{
return 31;
}
else if (months == [3])
{
return 30;
}
else if (months == [4])
{
return 31;
}
else if (months == [5])
{
return 30;
}
else if (months == [6])
{
return 31;
}
else if (months == [7])
{
return 31;
}
else if (months == [8])
{
return 30;
}
else if (months == [9])
{
return 31;
}
else if (months == [10])
{
return 30;
}
else if (months == [11])
{
return 31;
}
}
document.write(DaysInAMonth(1));
javascript
New contributor
I would like to write all the dates, days and months of 2019 in JavaScript. By using 3 functions. I only found 1 function I could use but I don't get it to work out. Anyone have some ideas or tips? Thanks. PS. I am sorry if I posted this wrong or made some misstakes.
EDIT: I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations.
document.writeln("Days in 2019 is:");
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
for (var i = 0; i<=months.length; i++)
{
for (var k = 1; k<=31; k++)
{
document.write(months[i]);
document.writeln(k);
}
}
function rightAdjust(x, size)
{
x = "" + x; // secure that x is a string
var noOfBlanks = size - x.length;
var blanks = "";
for (var i = 0; i < noOfBlanks; i++)
{
blanks = blanks + " ";
}
return blanks + x;
}
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var days;
days = DaysInAMonth(k);
for (var i = 0; i<=months.length; i++){
for (var k = 1; k<=days.length; k++)
{
document.write(months[i]);
document.writeln(days);
}
}
function DaysInAMonth(days)
{
var result;
if (months == [0])
{
return 31;
}
else if (months == [1])
{
return 28;
}
else if (months == [2])
{
return 31;
}
else if (months == [3])
{
return 30;
}
else if (months == [4])
{
return 31;
}
else if (months == [5])
{
return 30;
}
else if (months == [6])
{
return 31;
}
else if (months == [7])
{
return 31;
}
else if (months == [8])
{
return 30;
}
else if (months == [9])
{
return 31;
}
else if (months == [10])
{
return 30;
}
else if (months == [11])
{
return 31;
}
}
document.write(DaysInAMonth(1));
javascript
javascript
New contributor
New contributor
edited 28 mins ago
mdfst13
17.4k52156
17.4k52156
New contributor
asked 1 hour ago
SlipsknuteN
12
12
New contributor
New contributor
"By using 3 functions.": is that a requirement? What exactly are your requirements?
– trincot
1 hour ago
Yes that's a requirement. I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations
– SlipsknuteN
59 mins ago
I'd check your main loop, it's printing beyond December for a month and there seems to be an unidentified function around the line that reads: ' code document.writeln(days); ` I was able to see this on js.do That and some minor formatting, but that's the easy part!
– KoshVorlon
47 mins ago
Hey! Yeah, I removed months.length and wrote there 11 instead so I got unidentified. Thanks for tips though!
– SlipsknuteN
38 mins ago
The problem is that I want to get the array to work instead of at the end. then this whole must enter the "for-preset"
– SlipsknuteN
36 mins ago
|
show 2 more comments
"By using 3 functions.": is that a requirement? What exactly are your requirements?
– trincot
1 hour ago
Yes that's a requirement. I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations
– SlipsknuteN
59 mins ago
I'd check your main loop, it's printing beyond December for a month and there seems to be an unidentified function around the line that reads: ' code document.writeln(days); ` I was able to see this on js.do That and some minor formatting, but that's the easy part!
– KoshVorlon
47 mins ago
Hey! Yeah, I removed months.length and wrote there 11 instead so I got unidentified. Thanks for tips though!
– SlipsknuteN
38 mins ago
The problem is that I want to get the array to work instead of at the end. then this whole must enter the "for-preset"
– SlipsknuteN
36 mins ago
"By using 3 functions.": is that a requirement? What exactly are your requirements?
– trincot
1 hour ago
"By using 3 functions.": is that a requirement? What exactly are your requirements?
– trincot
1 hour ago
Yes that's a requirement. I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations
– SlipsknuteN
59 mins ago
Yes that's a requirement. I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations
– SlipsknuteN
59 mins ago
I'd check your main loop, it's printing beyond December for a month and there seems to be an unidentified function around the line that reads: ' code document.writeln(days); ` I was able to see this on js.do That and some minor formatting, but that's the easy part!
– KoshVorlon
47 mins ago
I'd check your main loop, it's printing beyond December for a month and there seems to be an unidentified function around the line that reads: ' code document.writeln(days); ` I was able to see this on js.do That and some minor formatting, but that's the easy part!
– KoshVorlon
47 mins ago
Hey! Yeah, I removed months.length and wrote there 11 instead so I got unidentified. Thanks for tips though!
– SlipsknuteN
38 mins ago
Hey! Yeah, I removed months.length and wrote there 11 instead so I got unidentified. Thanks for tips though!
– SlipsknuteN
38 mins ago
The problem is that I want to get the array to work instead of at the end. then this whole must enter the "for-preset"
– SlipsknuteN
36 mins ago
The problem is that I want to get the array to work instead of at the end. then this whole must enter the "for-preset"
– SlipsknuteN
36 mins ago
|
show 2 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
SlipsknuteN is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210497%2fsimple-calendar-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
SlipsknuteN is a new contributor. Be nice, and check out our Code of Conduct.
SlipsknuteN is a new contributor. Be nice, and check out our Code of Conduct.
SlipsknuteN is a new contributor. Be nice, and check out our Code of Conduct.
SlipsknuteN is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210497%2fsimple-calendar-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"By using 3 functions.": is that a requirement? What exactly are your requirements?
– trincot
1 hour ago
Yes that's a requirement. I need a function of NameOfTheMonths, NameOfTheWeekdays and DaysInAMonth. One function of each. No prints should be present in functions, all prints should be made in connection with the iterations
– SlipsknuteN
59 mins ago
I'd check your main loop, it's printing beyond December for a month and there seems to be an unidentified function around the line that reads: ' code document.writeln(days); ` I was able to see this on js.do That and some minor formatting, but that's the easy part!
– KoshVorlon
47 mins ago
Hey! Yeah, I removed months.length and wrote there 11 instead so I got unidentified. Thanks for tips though!
– SlipsknuteN
38 mins ago
The problem is that I want to get the array to work instead of at the end. then this whole must enter the "for-preset"
– SlipsknuteN
36 mins ago