Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
p5js-week-12 [2022/07/16 08:10] renickp5js-week-12 [2023/06/29 23:02] (current) reina.chen
Line 5: Line 5:
 (photo from https://www.flickr.com/photos/healthserviceglasses/3256234213) (photo from https://www.flickr.com/photos/healthserviceglasses/3256234213)
  
-Last time, we looked at if-statements and used them to check a toaster. Remember, here's the basic pattern for an if statement:+Last time, we looked at <color black/pink>if-statements</color> and used them to check a toaster. Remember, here's the basic pattern for an if statement:
  
   if () {} else {}   if () {} else {}
Line 24: Line 24:
 ====== using else ====== ====== using else ======
  
-We use "else" to handle every case that isn't handled by our condition. Above, the condition is "toasterPluggedIn == true"; anything else gets caught by "else"+We use <color black/yellow>"else"</color> to handle every case that isn't handled by our condition. Above, the condition is "toasterPluggedIn == true"; anything else gets caught by "else"
  
   toasterPluggedIn = "i forgot"    toasterPluggedIn = "i forgot" 
Line 77: Line 77:
 ====== using else if ====== ====== using else if ======
  
-Sometimes we have more than one condition; in those cases, we can continue to use new "ifs" with "else if". Finally, we present "else" to catch anything that isn't covered by our "ifs".+Sometimes we have more than one condition; in those cases, we can continue to use new "ifs" with <color black/yellow>"else if"</color>. Finally, we present "else" to catch anything that isn't covered by our "ifs".
  
 We can modify our basic if-statement reference to include else if like this: We can modify our basic if-statement reference to include else if like this:
Line 87: Line 87:
 ===== the includes method ===== ===== the includes method =====
  
-To do that, let's learn a new JavaScript method called "includes". "includes" checks a string to see if part of it matches the argument. Use it like this:+To do that, let's learn a new JavaScript method called "includes"<color black/pink>"includes"</color> checks a string to see if part of it matches the argument. Use it like this:
  
   "some delicious toast for breakfast".includes("toast")   "some delicious toast for breakfast".includes("toast")
  • p5js-week-12.txt
  • Last modified: 10 months ago
  • by reina.chen