top of page
Blog: Blog2
sal5014

Variables

This week cemented the importance of using variables when writing code. It saves you a headache in the end.


For our homework in pairs (link below) my partner and I decided to meet up and work together on both parts of our if statements. We decided to make a button that says "press me" and every time you click it it changes the background color to a random one but also sets a ball in motion towards one side or another. If you click the button again the ball goes the other way.


When we started the homework we thought it would be rather simple. But it turned out it took us a while to troubleshoot certain things. At first the background color would change when you pressed the button but also when you left the area designated for pressing the button (we later figured out that the placing of the background in random was incorrect as it was outside of our if statement which determined the edges of the button); then the button would disappear every time the background was re drawn (we figured out it was the order in which we wrote our code).

We also had an issue where the background would stay the same color when you clicked it but not when you ran the code again (we had random background in setup).


There were several little things that took a while to figure out but I think I really liked working in pairs. It was very good to bounce ideas off each other and troubleshoot the problems together. I really enjoyed being able to suggest ideas that worked and/or have immediate feedback on the ones that wouldn't work.


9 views0 comments

Recent Posts

See All

Comments


bottom of page