# ’15 -’16 General Discussion for Lesson 5.17

**URL:** <https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835>\
**Category:** Unit and Lesson Discussion\
**Tags:** csp-unit-5, csp-unit-5-lesson-17\
**Created:** [December 7, 2015, 8:13pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835 "2015-12-07T20:13:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brook](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/brook/32/88_2.png) [@brook](https://forum.code.org/u/brook)\
**Post date:** [December 7, 2015, 8:13pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835/1 "2015-12-07T20:13:29Z")

</div>

Use this thread to discuss your questions and comments about **how to run the lesson.**

---

<div class="post-metadata">

**Author:** ![mseeley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mseeley/32/743_2.png) [@mseeley](https://forum.code.org/u/mseeley)\
**Post date:** [April 22, 2016, 3:27pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835/2 "2016-04-22T15:27:29Z")

</div>

Re: setting a random stroke color in the canvas:

We’ve tried a bunch of ways to use setStrokeColor to set a random color, but I think we’re running into an issue where because the function accepts the parameter as a string, we can’t use randomNumber function for rgb values. We’ve also tried setting variables for the red, blue, and green separately and calling them in the setStrokeColor function, to no avail.

We’ve found a (kind of lame) workaround by creating an array made up of different colors, then calling for a random index using randomNumber – this works, but isn’t as “random” as we would like it, if that makes sense.

---

<div class="post-metadata">

**Author:** ![gtwrobel](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gtwrobel/32/3576_2.png) [@gtwrobel](https://forum.code.org/u/gtwrobel)\
**Post date:** [April 26, 2016, 2:50pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835/3 "2016-04-26T14:50:58Z")

</div>

Hey Michael,

You’re correct there is no random color function. I’ve made use of the following function in the past when trying to do what I believe you are.

```auto
function randomColor(){
  var r = randomNumber(0,255);
  var g = randomNumber(0,255);
  var b = randomNumber(0,255);
  //Create a string in the format "rgb(255, 100, 0)" and return it
  var colorString = "rgb(" + r + "," + g + "," + b + ")";
  return colorString; 
}

// In your code you can then call
setStrokeColor(randomColor());
// or to make the steps more explicit instead do
var newRandomColor = randomColor();
setStrokeColor(newRandomColor);

```

Let me know if that helps!  
GT

---

<div class="post-metadata">

**Author:** ![mseeley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mseeley/32/743_2.png) [@mseeley](https://forum.code.org/u/mseeley)\
**Post date:** [April 26, 2016, 2:56pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835/4 "2016-04-26T14:56:22Z")

</div>

That’s AWESOME. Makes perfect sense – setStrokeColor requires a string, so create a function that will return a string. Thank you!!!

---

<div class="post-metadata">

**Author:** ![gtwrobel](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gtwrobel/32/3576_2.png) [@gtwrobel](https://forum.code.org/u/gtwrobel)\
**Post date:** [April 26, 2016, 3:14pm UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835/5 "2016-04-26T15:14:33Z")

</div>

Glad that helped! 😄

---

<div class="post-metadata">

**Author:** ![brook](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/brook/32/88_2.png) [@brook](https://forum.code.org/u/brook)\
**Post date:** [December 13, 2016, 2:19am UTC](https://forum.code.org/t/15-16-general-discussion-for-lesson-5-17/2835/6 "2016-12-13T02:19:45Z")

</div>

Closed on December 13, 2016, 2:19am UTC


