- script.js
JavaScript
var red = 1;
var yellow = 2;
var green = 3;
var blue = 2;
if (blue != yellow) {
console.log('There are just as many blue markers as there are yellow ones. The forecast is moderately positive!');
} else {
console.log('Wrong! The forecast is unacceptable!');
}
if (blue == red) {
console.log('The numbers of blue and red markers are different. The forecast is positive!');
} else {
console.log('Wrong! The forecast is unacceptable!');
}
Result
Goalscompleted
Let’s correct the conditions and experiment a little.
- Replace
!=with==in the first condition. - Replace
==with!=in the second condition. - Set the variable
blueto the string value'2'instead of the number2and watch the result. Surprisingly, the comparisons will have the same results as before. - Now in the first
if, replace==with the strict equality operator===. This time, the first condition should be false.
Comments