CHAPTER 4: ADDITIONAL EXERCISES



Before we begin our first project, let's do some extra practice first, just to warm up. If you feel confident enough, feel free to skip this chapter.


EXERCISE 4.1

The following code is broken. Find the missing/incorrect symbols and put them in their place. Other parts of the syntax are broken as well.

table foo = {}

foo,d << "Cookies';
foo.t <- "Right"
foo.l = "Wakko";

foreach(local i in foo){
	print i, "\n";
};



EXERCISE 4.2

Create a table and add a function inside that prints any string you want. Call the function from outside the table. Redefine the function and call it again.

EXERCISE 4.3

Write a function that takes a string and prints the length of the string, followed by a newline character. Call the function with several different strings.


EXERCISE 4.4

Create a jagged array. Add either a nested for or while loop that prints out the full array, with all elements of the second dimension being on a shared line, and start a new line for each element of the first dimension.


That's enough warmup for now. Head on to the next section when you're ready to begin your project.

Are you enjoying this tutorial? If so, why not send a donation? You can do so by clicking the donate link at the top of the screen, and if you do, please attach a note to your payment letting me know it's for the tutorial!

<< PREV | NEXT >>