Some applications need to repeat behaviours. In this chapter we find out how to do this in JavaScript. We also learn how use JavaScript programs to create HTML document elements.