# U5 L8 Lockscreen Maker

**URL:** <https://forum.code.org/t/u5-l8-lockscreen-maker/35801>\
**Category:** Coding and Debugging Help\
**Created:** [January 31, 2022, 6:44pm UTC](https://forum.code.org/t/u5-l8-lockscreen-maker/35801 "2022-01-31T18:44:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmontgomery](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jmontgomery](https://forum.code.org/u/jmontgomery)\
**Post date:** [January 31, 2022, 6:44pm UTC](https://forum.code.org/t/u5-l8-lockscreen-maker/35801/1 "2022-01-31T18:44:10Z")

</div>

I’m having trouble helping one of my students. It seems to me the code should work, but he gets a white screen when he hits the location button. Here is his code:

// List of icons to randomly choose between  
var iconsList = [“icon://fa-heart”,  
“icon://fa-music”,  
“icon://fa-smile-o”,  
“icon://fa-globe”,  
“icon://fa-tree”,  
“icon://fa-bolt”,  
“icon://fa-moon-o”,  
“icon://fa-star”];  
var colorsList = [“red”, “green”, “yellow”, “blue”, “purple”, “pink”, “orange”];

RandomLocation();  
RandomColor();  
RandomIcon();

onEvent(“shapesButton”, “click”, function( ) {  
RandomIcon();  
});

onEvent(“locationsButton”, “click”, function( ) {  
RandomLocation();  
});

onEvent(“colorsButton”, “click”, function( ) {  
RandomColor();  
});

function RandomIcon() {  
setProperty(“homeScreen”, “image”, iconsList[(randomNumber(0, 7))]);  
}  
function RandomColor() {  
setProperty(“homeScreen”, “icon-color”, colorsList[(randomNumber(0, 7))]);  
}  
function RandomLocation() {  
for (var i = 0; i \< 19; i++) {  
setProperty(“icon” + i, “x”, randomNumber(0, 230));  
setProperty(“icon” + i, “y”, randomNumber(0, 300));  
}  
}

---

<div class="post-metadata">

**Author:** ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)\
**Post date:** [January 31, 2022, 6:56pm UTC](https://forum.code.org/t/u5-l8-lockscreen-maker/35801/2 "2022-01-31T18:56:03Z")

</div>

Please provide more details along with a link to the project. It will help if you could fill in the details below: **[Feel free to delete everything in brackets before posting your request for debugging help.]**

**Link to the project or level:** [replace with link to the curriculum or get the “Share” link to a project]  
**What I expect to happen:** [replace with a detailed description of the behavior you’re trying to create]  
**What actually happens:** [replace with a detailed description of what actually happens when the code runs including any errors or unexpected behavior]  
**What I’ve tried:** [replace with a detailed description of what you’ve already tried to do to solve the problem]

---

<div class="post-metadata">

**Author:** ![jmontgomery](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jmontgomery](https://forum.code.org/u/jmontgomery)\
**Post date:** [January 31, 2022, 7:20pm UTC](https://forum.code.org/t/u5-l8-lockscreen-maker/35801/3 "2022-01-31T19:20:27Z")

</div>

**Link to the project or level:** ([App Lab - Code.org](https://studio.code.org/projects/applab/QjQEDXHTgxtpv5Zu8LlnpYwhnsgvxNIllNTxmQ1-AJU))  
**What I expect to happen:** I expect the location of the shape to change.  
**What actually happens:** On my student’s screen, the entire screen goes white when he clicks "Locations! " Nothing happens when I run his code and click the locations button.  
**What I’ve tried:** My student originally had this code: function RandomLocation() {  
setProperty(“icon” + 1, “height”, randomNumber(0, 200));  
setProperty(“icon” + 1, “width”, randomNumber(0, 200));  
setProperty(“icon” + 1, “x”, randomNumber(-10, 300));  
setProperty(“icon” + 1, “y”, randomNumber(-10, 400));  
}.

First, we tried changing the +1 to +i but that didn’t seem to solve the issue so then we tried adding the loop to get it to work.

---

<div class="post-metadata">

**Author:** ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)\
**Post date:** [January 31, 2022, 7:22pm UTC](https://forum.code.org/t/u5-l8-lockscreen-maker/35801/4 "2022-01-31T19:22:16Z")

</div>

I noticed that the student has not drawn any icons on the screen, so he/she cannot set their property yet. The RandomIcon method is changing the image on the homescreen, but not changing the image of the icons. The student needs to use a loop like he/she did in RandomLocation method and set the image property of all the icons to a random image from the list.
