mardi 6 août 2019

Why is my 'result' variable not being correctly defined by my if...else statement?

I wish to define the variable 'result' with an if-else statement.

// These variables will be used to test my if statement: 
var a = 10;
var b = 20;

// My if if statement here: 
var result; 
if (a < b) {   
    console.log('a is smaller'); 
} else {
    console.log('a is not smaller'); 
}

// This will log my result to the console: 
console.log(result);

My if-else statement is executing correctly, but I am having trouble defining the 'result' variable.

Aucun commentaire:

Enregistrer un commentaire