Prueba Fullstack
Prueba Fullstack
An example of a rotation pattern could be: 2,2,3. In this case, the first person in
the rotation would be on call 2 days, the following person in the rotation would
be on call 2 days, and the next person would be on call 3 days, and then the
pattern repeats.
This means that in the first week, Max is on call for the first 2 days, followed
by Paula on call for 2 days and then Roger on call for 3 days.
The second week starts with Daniela on call for 2 days, then Max for 2
days, Paula for 3 days
The third week starts with Roger on call for 2 days, then Daniela for 2 days
and Max for 3 days
The fourth week starts with Paula on call 2 days, then Roger 2 days
and Daniela 3 days.
After 4 weeks (28 days), the cycle repeats and all of the team members would
have been on call the same amount of days.
Your Task:
Complete the JavaScript code of the function whoIsOnCall() in the example
program below, using the least amount of lines of code, that returns the name of
the person on call based on a date, start date, pattern and group provided as
arguments to the function.
let vTestDateArr =
[new Date(2021, 7, 16),new Date(2021, 7, 23), new Date(2021, 7, 28)
,new Date(2021, 8, 8),new Date(2021, 8, 12)];
console.log(vTestDateArr[i].toLocaleDateString('en-US') + '
On call: ' + onCallName);
You must complete the whoIsOnCall() function and send us back the entire
program with your function in it.
When the template program is executed with your whoIsOnCall function in it,
the output should show the name of the person who is on call on the date that
was passed to your function. The template program assumes a start date of
august 16th, 2021 and it calls the function for a random set of 5 dates, a pattern
of 2,2,3 and a group of 4 people. With such input, your program must output:
IMPORTANT: Your function must work with any number of people in the
group, and any rotation pattern, and any input date and any start date. The
program template includes one example scenario to test the function, but
we will test it with different dates, groups and patterns.
The program must run and produce the desired output to be considered for
employment. If the program does not run or does not produce the right output,
you will be disqualified.
The algorithm should be efficient using the least number of lines of code.
Your function must validate that pDate is greater than pStartDate. If this
validation fails, the function must return an error string.
Variable names must be in English and use proper JavaScript notation (camel
case)
When operating with dates and/or strings, must use JavaScript standard
functions