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
Yuri [45]
3 years ago
14

Days of the week are represented as three-letter strings ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"). Write a javaScript f

unction solution that, given a string S representing the day of the week and an integer K (between 0 and 500), returns the day of the week that is K days later. For example, given S = "Wed" and K = 2, the function should return "Fri". Given S = "Sat" and K = 23, the function should return "Mon".
Computers and Technology
1 answer:
dmitriy555 [2]3 years ago
3 0

Answer:

function getDay(s, k){

var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];

var index=weekDays.findIndex(function(weekDay){return weekDay==s;});

return weekDays[(index+k)%7];

}

Explanation:

//this functions receive the next parameters:

//s which is the day of the week

//k the number of days after s week day

function getDay(s, k){

var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];

//variable index is the index in list weekDays of s

var index=weekDays.findIndex(function(weekDay){return weekDay==s;});

//use module operator % to get the remainder of the division (index+k)/7

//return the string value of the day

return weekDays[(index+k)%7];

}

You might be interested in
Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and sec
fiasKO [112]

Answer:

Step by step explanation along with code and output is provided below

Explanation:

#include<iostream>

using namespace std;

// print_seconds function that takes three input arguments hours, mints, and seconds. There are 60*60=3600 seconds in one hour and 60 seconds in a minute. Total seconds will be addition of these three  

void print_seconds(int hours, int mints, int seconds)

{

   int total_seconds= hours*3600 + mints*60 + seconds;

   cout<<"Total seconds are: "<<total_seconds<<endl;

}

// test code

// user inputs hours, minutes and seconds and can also leave any of them by  entering 0 that will not effect the program. Then function print_seconds is called to calculate and print the total seconds.

int main()

{

   int h,m,s;

   cout<<"enter hours if any or enter 0"<<endl;

   cin>>h;

   cout<<"enter mints if any or enter 0"<<endl;

   cin>>m;

   cout<<"enter seconds if any or enter 0"<<endl;

   cin>>s;

   print_seconds(h,m,s);

  return 0;

}

Output:

enter hours if any or enter 0

2

enter mints if any or enter 0

25

enter seconds if any or enter 0

10

Total seconds are: 8710

8 0
4 years ago
Why is it worth remembering “All people seem to need data processing”?
Rzqust [24]
The answer is .........C
3 0
4 years ago
Read 2 more answers
A_________is an orderly collection of fact &amp; information.
sammy [17]

Answer:

C. Database

Explanation:

4 0
3 years ago
Write C++
crimeas [40]

Answer:

u can see the answer in this picture

5 0
2 years ago
What is the purpose of the boot loader during the bootup process
earnstyle [38]
To start up windows and boot the system to make sure no hackers or viruses are on windows so your computer does not get infected with a hacker or virus 

hope this helps 
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following statements about Linux is not​ true? A. Linux works on all the major hardware platforms. B. It plays a ma
    5·1 answer
  • The darker shadow of an eclipse is called the penumbra.<br><br> True<br><br> False
    12·1 answer
  • Which of these image sizes takes the most storage space?
    8·2 answers
  • What is IaaS? For this service model, what are the resources the cloud vendor will provide/manage and what are the resources the
    15·1 answer
  • Select the correct answer.
    6·2 answers
  • Vannevar Bush imagined a desktop computing machine that would allow people to access data stored in various information centers
    13·1 answer
  • Guys, what does Product Analysis mean? please say it in a simple way.
    10·1 answer
  • What is the full form of 'Rom<br>​
    7·2 answers
  • What is the answer???​
    6·1 answer
  • A computer is defined by 4 specific criteri. Select all 4.*
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!