+ 1
The if statement - JS
Please help: Sundays in Switzerland are protected with Quiet Rules which make it illegal to pursue certain activities. Taking the day of the week as input, output to the console "Obey the rules" if it is Sunday. Sample Input Sunday Sample Output Obey the rules Don't output anything if the input day isn't a Sunday. My code: function main() { var day = readLine(); var rules = 'Obey the rules'; // Your code goes here if (day = Sunday) { console.log(rules); } if (day != Sunday) { console.log() } }
2 Answers
+ 8
if (day == "Sunday")
⢠== for comparing the strings
⢠"Sunday" in "" because it needs to be a string
You can leave out the second if-statement if you don't need output
0
Got it, thanks!