0
I can only get either right or wrong but cant get both when i change the assignment operator to an equal operator. How do i fix?
function main() { var numberGuests = parseInt(readLine(), 10) if (numberGuests = "Even") { console.log("Right"); } else { console.log("Wrong"); } }
13 RĂ©ponses
0
using one â=â is to assign a value
â==â is to evaluate without caring for the type
â===â evaluates caring for the type.
var x = 1;
var y = â1â;
x==y is true
x===y is false
0
In other words, use â===â
0
I tried that and it still only gets half right
0
function main() {
var numberGuests = parseInt(readLine(), 10)
if ( numberGuests === "Even")
{
console.log("Right");}
else {
console.log("Wrong");
}}
0
what is readLine returning?
0
I have no idea i havent got that far in the lesson. The first 3 lines was already loaded do i need to delete it?
0
write console.log(numberGuests) above the if statement so you can see the output.
0
That just outputs numberGuests with the if statement.
0
Entrance 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".
0
if(numberGuests % 2 === 0){
console.log(ârightâ);
}else{
console.log(âwrongâ);
}
0
numberGuests % 2 will take the remainder. if it is zero, right if it is more than zero, wrong.
0
Thanks i got it now.
- 1
Thats the original question.