1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rufina [12.5K]
3 years ago
14

In the JavaScript file, find the if statement that checks whether the date string has slashes. Note that it’s only checking whet

her there is one or more slash. Then, modify the code so it checks to make sure that the date entry has two slashes. If not, display the same error message as shown above. To do this, you need to store the result of the indexOf method and use it to first check whether a first slash was found and then use it as the starting point for trying to find a second slash.
Computers and Technology
1 answer:
Alika [10]3 years ago
4 0

Answer:

"use strict";

var $ = function(id) { return document.getElementById(id); };

var calculateDays = function() {  

   var event = $("event").value;

   var dt = $("date").value;  

   var message = $("message").firstChild;  

   var date, days, today, oneDay;

   // clear previous message

   message.nodeValue = " ";

   //make sure task and due date are entered and correct

   if (event.length === 0 || dt.length === 0) {

       message.nodeValue = "Please enter both a name and a date.";

   } else {

       //make sure due date string has slashes and a 4-digit year

       // if there is just 1 slash, then lastIndexOf should be

       // same as indeof

       if (dt.indexOf("/") === -1 || dt.indexOf("/") === dt.lastIndexOf("/")) {

           message.nodeValue = "Please enter the date in MM/DD/YYYY format.";

       }

       var year = dt.substring(dt.length - 4);

       if (isNaN(year)) {

           message.nodeValue = "Please enter the date in MM/DD/YYYY format.";

       }  

       //convert due date string to Date object and make sure date is valid

       date = new Date(dt);

       if (date === "Invalid Date") {

           message.nodeValue = "Please enter the date in MM/DD/YYYY format.";

       }

   }  

   // if no error messages, calculate and display days until event

   if (message.nodeValue === " ") {

       //calculate days

       today = new Date();

       oneDay = 24*60*60*1000; // hours * minutes * seconds * milliseconds    

       days = ( date.getTime() - today.getTime() ) / oneDay;

       days = Math.ceil(days);

       //create and display message

       if (days === 0) {

           message.nodeValue = "Hooray! Today is " + event + "!";

       }

       if (days < 0) {

           event = event.substring(0,1).toUpperCase() + event.substring(1); // capitalize event

           message.nodeValue = event + " happened " + Math.abs(days) + " day(s) ago.";    

       }

       if (days > 0) {

           message.nodeValue = days + " day(s) until " + event + "!";

       }

   }

};

window.onload = function() {

   $("countdown").onclick = calculateDays;

   $("event").focus();

};

Explanation:

You might be interested in
What is the first step a user should take toward generating an index?
Ad libitum [116K]

Answer:

I think that it's A

Explanation:

5 0
3 years ago
How do Web browsers interact with URL/URIs to navigate the internet
iVinArrow [24]

Answer:

They smart dats y!

Explanation:

6 0
3 years ago
FS and GS are two___________________ in protected mode.
masha68 [24]

Answer:

Segment registers

Explanation:

The initial purpose behind the segment registers was to enable a program to access many distinct (big) memory sections designed to be autonomous and part of a constant virtual store.

They don't have a processor-defined objective, but instead Operating system runs them for purpose. The GS register is used in Windows 64-bit to point to constructions defined by the operating scheme.   Operating system kernels usually use FS and GS to access thread-specific memory. In windows, thread-specific memory is managed using the GS register. To access cpu-specific memory, the linux kernel utilizes GS.

7 0
3 years ago
Describe the type of gameplay seen during early video games (ex. Spacewar!, Pong).
Elina [12.6K]
  • Sandbox. ...
  • Real-time strategy (RTS) ...
  • Shooter (FPS and TPS) ...
  • Multiplayer online battle arena (MOBA) ...
  • Role-playing games (RPG, ARPG, and more) ...
  • Simulation and sports.

<em>-</em><em> </em><em>BRAINLIEST</em><em> answerer</em>

3 0
3 years ago
Read 2 more answers
This unit is used to print the picture on a paper
NeTakaya

Answer:a printer

Explanation:

It prints things

7 0
3 years ago
Other questions:
  • How do you know if you get a phone call that is a scam
    8·2 answers
  • What is computer? Explain the characteristics of computer.<br>​
    12·1 answer
  • A technician wants to create a new partition on a new additional hard drive. what tool should be used?
    15·1 answer
  • There are several factors that can substantially affect the consumer search process. Match the factor with an example of how the
    5·1 answer
  • how to answer the questions on brainly? I've typed my answer in the box but there's no submit button or whatever, and the only t
    14·2 answers
  • 1. What are the built-in operations on classes?
    8·1 answer
  • Was just testing how this works, no actual question; feel free to take the points anyways though. ​
    13·1 answer
  • To excel at these professions, you need to be able to combine an eye for elegant design with a mind that delights in efficient o
    8·1 answer
  • The courts can adjust the penalties in lawsuits to reflect the fact that infringements may be _____.
    5·2 answers
  • What are the main differences between openldap and microsoft's active directory (ad)? check all that apply
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!