If statements | Sololearn: Learn to code for FREE!

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); } }

11/27/2020 12:05:20 PM

Yasamin Kholafaei

2 Answers

New Answer

+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");}