
上QQ阅读APP看书,第一时间看更新
Using the NOT operator to change the condition
Here's a little curveball to wrap your mind around: the NOT logical operator. It's written in code using an exclamation mark. This makes a true condition false, or a false condition true. Let's add a NOT operator to our statement. Line 10 should now look like this:
if ( ! willItBeRainingToday ) {
Press Play in the editor. You will notice that the decision̵1;making is now working the opposite way. Line 11 will be executed only if the willItBeRaining variable is false.