Why a I getting a TypeError in this JavaScript code? : I am a beginner JavaScript programmer and I am following a book called "Create with < code >" and I am having trouble with the code. I have been following along with the book but when I have tried running it, there is an error. I have been typing the code into a plain-text editor and viewing it on Chrome. I do not know how to fix this. Help?

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    <!DOCTYPE html>
    <html>
        <head>
            <title>Nanonaut Action</title>
        </head>
        <body>
            <script>
                //CONSTANTS
    			var CANVAS_WIDTH = 800;
    			var CANVAS_HEIGHT = 600;
    			
    			var NANONAUT_WIDTH = 181;
    			var NANONAUT_HEIGHT = 229;
    			var GROUND_Y = 540;
    			var NANONAUT_Y_ACCELERATION = 1;
    			var SPACE_KEYCODE = 32;
    			var NANONAUT_JUMP_SPEED = 20;
    			var NANONAUT_X_SPEED = 5;
    			var BACKGROUND_WIDTH = 1000;
    			var NANONAUT_NR_FRAMES_PER_ROW = 5;
    			var NANONAUT_NR_ANIMATION_FRAMES = 7;
    			var NANONAUT_ANIMATION_SPEED = 5;
    			
    			
                //SETUP
    			var gameFrameCounter = 0;
    			
    			var bushx
    			
    			
    			var cameraX = 0;
    			var cameraY	= 0;
    			var nanonautYSpeed = 0;
    			var nanonautIsInTheAir = false;
    			var spaceKeyIsPressed = false;
    			var nanonautFrameNr = 0;
    			var bushData = generateBushes();
    			var canvas = document.createElement('canvas');
    			var c = canvas.getContext('2d');
    			canvas.width = CANVAS_WIDTH;
    			canvas.height = CANVAS_HEIGHT;
    			document.body.appendChild(canvas);
    			
    			var nanonautImage = new Image ();
    			nanonautImage.src = 'animatedNanonaut.png';
    			
    			var backgroundImage = new Image ();
    			backgroundImage.src = 'background.png';
    			
    			var bush1Image = new Image ();
    			bush1Image.src = 'bush1.png';
    			
    			var bush2Image = new Image ();
    			bush2Image.src = 'bush2.png';
    			
    			var nanonautX = CANVAS_WIDTH / 2;
    			var nanonautY = GROUND_Y - NANONAUT_HEIGHT;
    			
    			window.addEventListener('keydown', onKeyDown);
    			window.addEventListener('keyup', onKeyUp);
    			
    			window.addEventListener('load', start);
    			
    			function start() {
    				window.requestAnimationFrame(mainLoop);
    			}
    			
    			function generateBushes() {
    				var generatedBushData = [];
    				var bushX = 0;
    				while (bushX < (2 * CANVAS_WIDTH)) {
    					var bushImage;
    					if (Math.random() >= 0.5) {
    						bushImage = bush1Image;
    					} else {
    						bushImage = bush2Image
    					}
    				generatedBushData.push ({
    					x: bushX,
    					y: 80 + Math.random() * 20,
    					image: bushImage
    			});
    				bushX += 150 + Math.random() * 200;
    				}
    				return generatedBushData;
    			}
    			
                //MAIN LOOP
    			function mainLoop() {
    				update();
    				draw();
    				window.requestAnimationFrame(mainLoop);
    				
    			}
    			
                //PLAYER INPUT

    			
    			function onKeyDown(event) {
    				if (event.keyCode === SPACE_KEYCODE) {
    					spaceKeyIsPressed = true;
    				
    				}
    			}
    			
    			function onKeyUp(event) {
    				if (event.keyCode === SPACE_KEYCODE) {
    					spaceKeyIsPressed = false;
    				
    				}
    			}
    			
                //UPDATING
    			function update() {
    				gameFrameCounter = gameFrameCounter + 1;
    				nanonautX = nanonautX + NANONAUT_X_SPEED;
    				
    				if (spaceKeyIsPressed && !nanonautIsInTheAir) {
    					nanonautYSpeed = - NANONAUT_JUMP_SPEED;
    					nanonautIsInTheAir = true;
    				}
    				
    				//Update Nanonaut
    				nanonautY = nanonautY + nanonautYSpeed;
    				nanonautYSpeed = nanonautYSpeed + NANONAUT_Y_ACCELERATION;
    				
    				if (nanonautY > (GROUND_Y - NANONAUT_HEIGHT)) {
    					nanonautY = GROUND_Y - NANONAUT_HEIGHT;
    					nanonautYSpeed = 0;
    					nanonautIsInTheAir = false;
    				}
    				
    				//Update animaion
    				if ((gameFrameCounter % NANONAUT_ANIMATION_SPEED) === 0) {
    					nanonautFrameNr = nanonautFrameNr +1;
    					if (nanonautFrameNr >= NANONAUT_NR_ANIMATION_FRAMES) {
    						nanonautFrameNr = 0;
    					}
    				}
    				
    				//Update camera
    				cameraX = nanonautX - 150
    				
    				//Update bushes.
    		for (var i=0; i<bushData.length; i++) {
    			if ((bushData[i].x - cameraX) < -CANVAS_WIDTH) {
    				bushData[i].x += (2 * CANVAS_WIDTH) + 150;
    			}
    		}
    			}


                //DRAWING
    			function draw() {
    				c.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
    				
    				//Draw the Sky.
    				c.fillStyle = 'LightSkyBlue';
    				c.fillRect(0, 0, CANVAS_WIDTH, GROUND_Y - 40);
    				
    				//Draw the background.
    				var backgroundX = - (cameraX % BACKGROUND_WIDTH);
    				c.drawImage(backgroundImage, backgroundX, -210);
    				c.drawImage(backgroundImage, backgroundX + BACKGROUND_WIDTH, -210);
    				
    				//Draw the bushes
    				for (var i=0; i<bushData.length; i++) {
    			c.drawImage(
    				bushData[i].image,
    				bushData[i].x,
    				GROUND_Y - bushData[i].y);
    		}
    				
    				//Draw the ground.
    				c.fillStyle = 'Green';
    				c.fillRect(0, GROUND_Y - 40, CANVAS_WIDTH, CANVAS_HEIGHT - GROUND_Y + 40);
    				
    				//Draw the Nanonaut.
    				var nanonautSpriteSheetRow = Math.floor(nanonautFrameNr / NANONAUT_NR_FRAMES_PER_ROW);
    				var nanonautSpriteSheetColumn = nanonautFrameNr % NANONAUT_NR_FRAMES_PER_ROW;
    				var nanonautSpriteSheetX = nanonautSpriteSheetColumn * NANONAUT_WIDTH
    				var nanonautSpriteSheetY = nanonautSpriteSheetRow * NANONAUT_HEIGHT
    				c.drawImage(nanonautImage, nanonautSpriteSheetX, nanonautSpriteSheetY, NANONAUT_WIDTH, NANONAUT_HEIGHT, nanonautX - cameraX, nanonautY - cameraY, NANONAUT_WIDTH, NANONAUT_HEIGHT);
    				

    			}
            </script>
        </body>
    </html>

<!-- end snippet -->

