Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I wanted the month to be like March not 3, please var log = \'<p>This is a messa

ID: 3726486 • Letter: I

Question

I wanted the month to be like March not 3, please

var log = '<p>This is a message in the console log.</p>';

function showCopy() {

var d = new Date();

var year = d.getFullYear();

var month = d.getMonth();

Months= ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

var footer = document.getElementsByTagName('footer')[0];

var p = document.createElement('p');

p.innerHTML = '&copy; '+ (month+Months+1)+ ' '+year +' by Abiodun Ogunwomoju. All Rights Reserved.';

footer.appendChild(p);

log += '<p> A paragraph has been added to the footer. </p>';

}

window.onload = showCopy;

Explanation / Answer

Below is the modified code tot the given code. modified part is been in bold text.

<html>
<body>
<script>  
var log = '<p>This is a message in the console log.</p>';

function showCopy()
{

var d = new Date();

var year = d.getFullYear();

var month = d.getMonth();

Months= ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

var footer = document.getElementsByTagName('footer')[0];

var p = document.createElement('p');

//since Months is an array of months, we can simply use index as month to get the Month as text. Ex: April
p.innerHTML = '&copy; '+ (Months[month])+ ' '+year +' by Abiodun Ogunwomoju. All Rights Reserved.';

footer.appendChild(p);

log += '<p> A paragraph has been added to the footer. </p>';

}

window.onload = showCopy;
</script>  
<footer>
</footer>
</body>
</html>

Output:

© March 2018 by Abiodun Ogunwomoju. All Rights Reserved.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote