02-02-seeing-stars.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. Ninjas practice using the spin function on three different objects.
  3. New Vocabulary and Concepts
  4. * Logs and Errors
  5. Reinforced Vocabulary and Concepts
  6. * Functions and Parameters
  7. * GDP spin() function
  8. * Object Names
  9. Sensei Notes
  10. * The Ninjas will not add any objects to the scene.
  11. * This activity introduces an error on purpose to stress the importance of GDP object names. The Debug tab is
  12. not a focus of the White Belt.
  13. Solution Steps
  14. 1 Make sure the Ninja opens the correct scene.
  15. 2 Make sure the Ninja is on the correct object and in the correct event.
  16. 3 This piece of code is the same as the first piece of code in the previous activity. The Ninjas need to realize
  17. that the GDP acts on objects with specific names. There is not an object named "star' in this scene, so the
  18. GDP does not know what to do.
  19. spin(star, 10);
  20. 4 No stars should be spinning. You can ask the Ninja what they think is wrong, but they should not know why
  21. at this point.
  22. 5 This is could be the Ninja's first scene that is "broken," so stress that debugging is part of programming.
  23. There is no "right" or "wrong" answer or way to program. The Error in the console should be "ReferenceError:
  24. star is not defined."
  25. 6 Explain that each object has a unique name and that the names of the three stars in this scene are
  26. yellowStar, orangeStar, and greenStar.
  27. 7 Have the ninja change only the first parameter from star to yellowStar. When the Ninja plays the game, only
  28. the yellow star should be spinning.
  29. 8 This is the first time that the Ninja is adding more than one line of code. Make sure they understand the enter
  30. key moves to the next line. When the Ninja plays, the yellow and orange stars should be spinning at the
  31. same exact rate.
  32. 9 This is the first time Ninjas are expected to produce their own line of code from nothing. If they struggle,
  33. help them use the existing two lines as a model for the new line. The first parameter should now be
  34. greenStar.
  35. 10 Before the Ninja submits their game, make sure they understand the purpose of functions. We can ask the
  36. GDP to perform actions on objects. While pieces of functions might change, they always have a name,
  37. parentheses, and zero or more parameters.
  38. */
  39. spin(yellowStar, 10);
  40. spin(orangeStar, 10);
  41. spin(greenStar, 10);
  42. /**
  43. Sensei Stops
  44. 5 Tello Sensei whot you think this error means. What does it mean when it soys, "star is not defined?"
  45. Ask the Ninja what "star" is in this context. Remind them that it was referring to an object in the scene. Ask
  46. the Ninja what happens if you call them by the wrong name? Would they respond? Of course not! That must
  47. mean that we don't have the correct name of any of the stars.
  48. 10 Tell a Sensei about line 3 of your code. How did you know what name to use? What are the components of a
  49. function?
  50. It is important to understand the thought process of the Ninja. They came up with the code on their own, so
  51. ask how they knew what to type. See if they remember the definitions of function and parameter. See if they
  52. remember the parameters of the spin function.
  53. */