Help me to write code for this

Objective:

write a function to find expiry datetime. expiry datetime is 3 working hours from “now”.
the working hours is defined in “schedule” input parameter.
You can write the function in java or javascript programming language.

input parameters:

now: datetime, current datetime. e.g: ‘2019-10-11T08:13:07+0800’
schedule: an arraylist of map object. which specified the day open or close and also the start and end of working hours
[
{“open”: false, “open_at”: “”, close_at: “”}, // sunday
{“open”: true, “open_at”: “09:00”, close_at: “18:00”}, // monday
{“open”: true, “open_at”: “09:00”, close_at: “18:00”},
{“open”: true, “open_at”: “09:00”, close_at: “18:00”},
{“open”: true, “open_at”: “09:00”, close_at: “18:00”},
{“open”: true, “open_at”: “09:00”, close_at: “17:00”},
{“open”: false, “open_at”: “”, close_at: “”},
]

example:

now is friday 4pm. whith the above schedule, the expiry date should be next monday 11 am. because on friday office close
at 5pm and office is closed on weekend.
output: datetime, 3 working hour from input date (“now”), which is 11 am of next monday

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

function myFunction(now) {

    var cdate = now;
    console.log(cdate);
    var day = cdate.getDay();
    console.log(day);
    var schedule = [
        { "open": false, "open_at": "", close_at: "" }, // sunday
        { "open": true, "open_at": "09:00", close_at: "18:00" }, // monday
        { "open": true, "open_at": "09:00", close_at: "18:00" },
        { "open": true, "open_at": "09:00", close_at: "18:00" },
        { "open": true, "open_at": "09:00", close_at: "18:00" },
        { "open": true, "open_at": "09:00", close_at: "17:00" },
        { "open": false, "open_at": "", close_at: "" },
    ];

    if ((schedule[day].open)) {
        console.log(new Date(now.getTime() + (3 * 60 * 60 * 1000)))
    } else {
        console.log(schedule[day].open);
    }
}
Title of the document

There is a hidden message for you. Click to see it.

Click me!