java script scratch code - example functions, data structures, practise control loops