- 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('There are not as many blue markers as there are red ones. The forecast is positive!');
} else {
console.log('Wrong! The forecast is unacceptable!');
}
Result
Goalscompleted
Let’s correct the conditions and experiment a little.
- Replace
!=
to==
in the first condition. - Replace
==
to!=
in the second condition. - Set the variable
blue
to the string value'2'
instead of a number one and watch the result. Surprisingly, the conditions will work as before. - Now in the first
if
, replace==
with the operator of strict correspondence===
. This time, the first condition must not be fulfilled.
Comments