Replacing Tuples With Arrays

The rota rotates, but its header still needs the out-of-hours window: six in the evening until eight the next morning. Python keeps those hours in a tuple. JavaScript has no tuple type, so you need another shape for that fixed pair.

Port the Hours Together

The Python script reads the tuple by position:

Language: Python
ON_CALL_HOURS = (18, 8)
print(ON_CALL_HOURS)
print(f"Out of hours: {ON_CALL_HOURS[0]}:00 to {ON_CALL_HOURS[1]}:00")

Python prints both hours:

Language: Program Output
(18, 8)
Out of hours: 18:00 to 8:00

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.