Code: Functions: Use and Use Again

We intentionally broke a lot of things as we explored functions in Chapter 5, Functions: Use and Use Again. A copy of the code that works follows (note that it doesn’t include the recursion example).

 
<body>​</body>
 
<script src="http://gamingJS.com/Three.js​"></script>
 
<script src="​http:​//gamingJS.com/ChromeFixes.js"></script>
 
<script>
 
var​ log = makeLog();
 
logMessage(hello(​"President Obama"​), log);
 
logMessage(hello(​"Mom"​), log);
 
logMessage(hello(​"Purple Fruit Monster"​), log);
 
logMessage(hello(​"Chris"​), log);
 
 
/*
 
// Missing a curly brace - this won't work!
 
function hello(name) {
 
return 'Hello, ' + name + '! You look very pretty today :)';
 
​​
 
*/
 
 
function​ hello(name) ...

Get 3D Game Programming for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.