0
If statements
Whats the problem for this code of this task ? eEntrance to the club is only permitted in pairs. Take the number of customers in the club as input, and, if all of them have a pair, output to the console "Right", otherwise output "Wrong". Sample Input 14 Sample Output Right function main() { var numberGuests = parseInt(readLine(), 10) if (numberGuests%2 = 0) { document.write(Right); } else { document.write(Wrong); } }
3 odpowiedzi
+ 3
Yasamin Kholafaei , change first the if condition to numberGuests % 2 === 0, then "Right" and "Wrong" should be in quotes. For console output use console.log () method instead of document.write ().
+ 1
//let 'n' represent our number of remainders
var n = numberGuests % 2;
if(n == "0")
console.log("Right");
else{console.log("Wrong");}
Or you can say for short
If(numberGuests % 2 == "0")
console.log("Right");
else{console.log("wrong");}
0
Write a program that checks if the water is boiling.
Take the integer temperature in Celsius as input and output "Boiling" if the temperature is above or equal to 100.