9 Javascript Exercises
9 Javascript Exercises
The exercises below get you started with JavaScript (JS). Try to follow the instructions and write down your answers not only your program but as well your reasoning. I dont care how you document your reasoning, either as comments of the JS program, as Word document, on a paper, or in whatever way you prefer but it is important that you write your reasoning down. The observation that I make on myself is that if Im not writing down the reasoning to that type of questions, I have the impression that I have the solution for the problem whereas in fact as it turns out later I dont. It is normal to get stuck with at least one of the exercises. Dont hesitate to first ask your friendly neighbor (but dont let them touch your mouse and keyboard!!). If that doesnt help, you are asked to talk to me! Teamwork is appreciated tough it is important that you touch mouse and keyboard yourself. So talk to your neighbor about how to conceptually solve the problem but dont let them touch your mouse and keyboard! Feel free to expand the exercises and solve your own tasks! Expanding and exploring is much appreciated and I truly believe that in the end, this is the only way to get a really good feeling for a language. On \\mail\students\it-workshop\9-css\ you can find the solutions for the exercise. Refrain from consulting them before you really have been fighting there are no shortcuts on the way to learn how to program!
4. Add a Comment
At the beginning of the file 3-alert.js, add a comment that describes what is happening in this file. A possible comment could be: /* This function opens an alert box that greets you ;-)! */
5. Define a Variable
Create files 5-variable.js and 5-variable.html. In 5-variable.js, add the function showHello() from Exercise 3. Instead of directly outputting the message Hello, you save this message into a variable. Make sure that you choose a valid name for the variable consult the slides! Use then the variable to output the message. In the end, your 5-variable.js should look more or less like this: function showHello() {
var message = "Hello"; alert(message); } Include the file 5-variable.js into 5-variable.html and call the function with the help of a link (as you did in Exercise 3).
What happens if you use 10.2 as an input? Does that make sense? What happens if the user inputs a letter instead of a number? Use the files 14-sum.js and 14-sum.html.
16. JavaScriptKara
Getting bored? Already done with all the exercises? Open the file d:/itworkshop/javascriptkara-en.jar and solve a few of the exercises that are provided. I suggest that you start with the easiest ones and work your way to the top, e.g. as follows: 1. Kara, the tunnel seeker I 2. Kara, the tunnel seek II 3. Searching cloverleafs in a forest I 4. Searching cloverleafs in a forest III 5. Kara and the cloverleafs 6. PacMan with cloverleafs 7. Follow trees 8. Slalom 9. Draw spirals 10. Draw triangles 11. Searching cloverleafs in a forest II 12. Mazes