0

How to write a javascript program to accept 1 to 7 numbers from user and display appropriate week of the days

15th Mar 2022, 12:37 PM
Fatema Bohari
Fatema Bohari - avatar
3 Réponses
+ 1
Given code only accept a number between 1 to 7 and return day of week. I hope you understand :) https://code.sololearn.com/W9y24rFbl2v0/?ref=app
15th Mar 2022, 1:08 PM
SAN
SAN - avatar
+ 7
In this way :- const day = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; var input = parseInt(prompt("Enter a number between 1 to 7")); console.log(day[input-1])
15th Mar 2022, 12:54 PM
☆~Monu~☆
☆~Monu~☆ - avatar
+ 5
Take week days in to a array. Take user input by prompt.. (1 to 7) Display array[input-1]
15th Mar 2022, 12:52 PM
Jayakrishna 🇮🇳