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
aleksley [76]
2 years ago
9

Have the javascript function CountingMinutes(str) take the str parameter being passed which will be two times (each properly for

matted with a colon and am or pm) separated by a hyphen and return the total number of minutes between the two times. The time will be in a 12 hour clock format. For example: if str is 9:00am-10:00am then the output should be 60. If str is 1:00pm-11:00am the output should be 1320.
function CountingMinutes(str) {
// code goes here
return str;
}
// keep this function call here
console.log(CountingMinutes(readline()));
Computers and Technology
1 answer:
jarptica [38.1K]2 years ago
5 0

Using the knowledge in computational language in Java it is possible to write a code that function as CountingMinutes:

<h3>Writing the code in Java:</h3>

function CountingMinutes(str) {

     // code goes here  

     // Declare variables for calculating difference in minutes

     // variables in JavaScript are declared with "let" keyword

     /* Build regelar expression which will match the pattern of "12houttime-12hourtime"

        and extract time or hours in numbers from it */

     let extractedTimeStringArray = str.match(/(\d+)\:(\d+)(\w+)-(\d+)\:(\d+)(\w+)/);

     // extractedTimeStringArray array will be like- ["1:00pm-11:00am", "1", "00", "pm", "11", "00", "am", index: 0, input: "1:00pm-11:00am", groups: undefined]    for str = "1:00pm-11:00am"

     // console.log('object', time)

     

     // Extract array value at 1st index for getting first time's hours (ie time before hyphen like 1:00pm in 1:00pm-11:00am )  (like 11 from 11:32am) and convert them to minutes by multiplying by 60

     let mintsOfFirstTimeFromHours = extractedTimeStringArray[1] * 60;

     // Extract array value at 2nd index for getting first time's minutes like 32 from 11:32am

     let mintsOfFirstTimeFromMints = extractedTimeStringArray[2];

     // Extract array value at 4th index for getting second time's hours (ie time after hyphen like 11:00am in 1:00pm-11:00am ) and convert them to minutes by multiplying by 60

     let mintsOfSecondTimeFromHours = extractedTimeStringArray[4] * 60;

     // Extract array value at 5th index for getting second time's minutes like 32 from 11:32am

     let mintsOfSecondTimeFromMints = extractedTimeStringArray[5];

     // if second time's 12 hour time is in pm

     if (extractedTimeStringArray[6] === "pm") {

       // Add 12 * 60 = 720 minutes for 12 hrs

         mintsOfSecondTimeFromHours += 720;

     }

     // if first time's 12 hour time is in pm

     if (extractedTimeStringArray[3] === "pm") {

        // Add 12 * 60 = 720 minutes for 12 hrs to first time

       mintsOfFirstTimeFromHours += 720;

        // Add 12 * 60 *2 = 1440 minutes for 24 hrs to second time

       mintsOfSecondTimeFromHours += 1440;

     }

     // Calculate output minutes difference between two times separated by hyphen

    str = (mintsOfSecondTimeFromHours - mintsOfFirstTimeFromHours) + (mintsOfSecondTimeFromMints - mintsOfFirstTimeFromMints);

     // return calculated minutes difference

     return str;

   }

   // keep this function call here

   // call the function and console log the result

   console.log(CountingMinutes("1:00pm-11:00am"));

   // output in console will be-  1320

See more about Java at: brainly.com/question/12975450

#SPJ1

You might be interested in
Free points,
Radda [10]

Answer:

thank you i really needed that and plus i just lost point by putting a question i mean i was asking for help and i still don't know the answer

hope u feel better

5 0
3 years ago
Read 2 more answers
A drowsy cat spots a flowerpot that sails first up and then down past an open window. The pot is in view for a total of 0.50 sec
GaryK [48]

Answer:

2.342m

Explanation:

Given

Time = 0.5 s

Height of Window = 2m

Because the pot was in view for a total of 0.5 seconds, we can assume that it took the cat 0.25 seconds to go from the bottom of the window to the top

Using this equation of motion

S = ut - ½gt²

Where s = 2

u = initial velocity = ?

t = 0.25

g = 9.8

So, we have.

2 = u * 0.25 - ½ * 9.8 * 0.25²

2 = 0.25u - 0.30625

2 + 0.30625 = 0.25u

2.30625 = 0.25u

u = 2.30625/0.25

u = 9.225 m/s ------------ the speed at the bottom of the pot

Using

v² = u² + 2gs to calculate the height above the window

Where v = final velocity = 0

u = 9.225

g = 9.8

S = height above the window

So, we have

0² = 9.225² - 2 * 9.8 * s

0 = 85.100625 - 19.6s

-85.100625 = -19.6s

S = -85.100625/19.6

S = 4.342

If 4.342m is the height above the window and the window is 2m high

Then 4.342 - 2 is the distance above the window

4.342 - 2 = 2.342m

6 0
3 years ago
PLEASEEE HELPPPP me
insens350 [35]

Answer:

D

Hope This Helps!   Have A Nice Day!!

7 0
3 years ago
Company A is setting up a network of mostly Windows machines. Which networking file system protocol would you recommend for maxi
maxonik [38]

Answer:

For maximum interoperability, NFSv4 is recommended.

Explanation:

When setting up a network of mostly windows machines, it is better to use NFSv4 because it includes performance improvements, mandates strong security, and a stateful protocol.

4 0
3 years ago
Hulu suggestions? I just got it and I wanna know what's good :)
o-na [289]
Anime show: naruto

Drama show: sweet Mongolian

Adventure show: outer banks
6 0
3 years ago
Read 2 more answers
Other questions:
  • You '' friend or ''like'' a page o your favorite social media page that advertises a
    10·1 answer
  • In the written Hawaiian language, only 13 letters are used: the five vowels (a,e,i,o, and u), and 8 consonants (h,k,l,m,n,p,w, a
    10·1 answer
  • What do character formats do for your document's message? A. Set how text aligns within a document B. Provide organization C. Pr
    6·2 answers
  • A sense of scale tells us what about the objects in a picture?
    11·2 answers
  • The variable most_recent_novel is associated with a dictionary that maps the names of novelists to their most recently published
    12·1 answer
  • Who created fortnite
    15·2 answers
  • A-1 grdening supply is preparing a reprt to hand out to the customerez in pointes form only.why should the reprts writers avoid
    9·2 answers
  • Which browser feature will delete your history, cache, and cookies the moment you close the special window
    6·1 answer
  • A company creates a ______by using a wireless access point (WAP) and an Internet connection. Select the two correct answers, the
    11·1 answer
  • Why is a salt added to a password that is being stored in a database?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!