+ 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() } }

4th Jan 2021, 6:44 PM
K.C. Lavington
K.C. Lavington - avatar
2 ответов
+ 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
4th Jan 2021, 6:52 PM
Lisa
Lisa - avatar
0
Got it, thanks!
4th Jan 2021, 7:13 PM
K.C. Lavington
K.C. Lavington - avatar