Need help finishing a javascript probleme

homework
js

#1

I need to create a .js to use on a web page to show that days events.
first I needed to declare a var named thisDate containg October 12, 2018.

second create a var dateString containg the text of thisDate using local conventions.

third a dateHMTL var with the text string

date

.

fourth make thisDay var containing the day of the week number from the thisDate var

fifth use the thisDay var as a parameter value call the getEvent function to get the HTML code of that days events and store it in a var called eventHTML

lastly apply the insertAdjacentHTML() method to the page element with the id unionToday insert the value of dateHTML plus eventHTML var before the end of the element

here is my code so far
function getEvent(day) {

var thisDate = new Date("October 12, 2018");
var dateStr = thisDate.toLocaleDateString();

var dateHTML = "<h2>" + dateStr + "</h2>";

var thisDay = new Date();
document.write(thisDay.getDay());
var eventHTML = ;

element.insertAdjacentHTML(“unionToday”) + dateHTML + eventHTML;


#2

Where is the call to this function? And where in this function is the parameter, day even used? Seems there is lot of confusion going on here that needs to be sorted before this question can begin to get answers.


#3
> function getEventDate(date) {
      return new Date(date).toLocaleDateString();
  }
< undefined
> getEventDate("October 12, 2018")
< "10/12/2018"
> dateHTML = "<h2>" + getEventDate("October 12, 2018") + "</h2>"
< "<h2>10/12/2018</h2>"

Beyond all that, you are on your own. This is, after all, your homework.


#4

alright thank you for your help


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.