0
Getting stuck on Javascript Module 3 Pro Practice: Admission In Pairs
Admission In Pairs https://www.sololearn.com/learning/1024/1137/1398/1 Executing the same output. function main() { var numberGuests = parseInt(readLine(2),) var numberGuests = 2; if (numberGuests == 2){ console.log("Right"); } else if (numberGuests != 2) { console.log("Wrong"); } else { console.log("o"); } }
2 ответов
+ 1
/*
Try this code using
Conditional (ternary) operator
*/
function main() {
var numberGuests = parseInt(readLine(), 10)
// Your code here
numberGuests % 2 === 0 ? console.log("Right") : console.log("Wrong")
}
0
Try using % in your statement. This will give you a remainder which you can then compare to other numbers.
If (36 % 2 == 0) {
console.log("Right");
} else {
console.log("Wrong")