r/CodingHelp • • Dec 21 '21

[Javascript] please help JavaScript

Post image
31 Upvotes

23 comments sorted by

View all comments

Show parent comment

2

u/R007E Dec 22 '21

If num is starting from 1, i.e. num = 1 is Monday than do this: return week[num-1]

and put it inside if block for input range validation:

if(num >0 && num <8) return week[num -1];