JS Homework

Day 1

Follow the instructions below and output the answer to the console as well as dispaly on the page.

  1. Write the JavaScript to display the current day and time in the following format and output it to the html page to the span with an id of "answer1"

    Today is Monday.
    Current Time : 8:55:25 PM

    Answer:

    hello
  2. Write the JavaScript to display the current day and time in the following format and output it to the html page to the span with an id of "answer2"

    mm-dd-yyyy, mm/dd/yyyy and dd/mm/yyyy each on a seperate line.

    Answer:

    hello

  3. Write an HTML button below and when it clicks, it prints the content of the current html page (current window).



  4. Write a JavaScript program where the program takes a random integer between 1 to 5, the user clicks a button, an alert box pops up and the user is then prompted to input a guess number. If the user input matches with guess number, the program will display a message "Good Work" otherwise display a message "Not matched".

    Answer: