## Introduction

This page explains answers to JavaScript questions six through ten, for the Coding Maze games. Questions in the game display in random order. This page covers questions in sequential order, as the questions are stored in an array, for the game.

Each question was tested with Javascript in file, answers.js. JavaScript first saves an HTML element from the Web page. Element `eDebug` displays the value of `x` after each question.

```var eDebug = document.getElementById('eDebug');
```

### Question Six

Source code for the sixth question follows. The answer equals `-1`.

```x = 0;
y = -4;
x = y >> 2;
eDebug.innerHTML += "6. x:"+x+"<br />";
```

The signed right shift operator, `>>`, keeps the far left sign bit, then shifts bits to the right, based on the value of the operand. The far left sign bit, for `-4` equals `1`. A sign bit of `0` represents a positive number. A sign bit of `1` represents a negative number.

The 32 bit value of `-4`, assigned to variable `y`, in binary, follows.

```1000 0000 0000 0000, 0000 0000 0000 0100
```

Move bits, starting with the second bit from the left, to the right `2` places. The result equals `-1` as follows.

```1000 0000 0000 0000, 0000 0000 0000 0001
```

### Question Seven

Source code for the seventh question follows. The answer equals Roy.

```y = {age:20,name:"Roy"}
x = y.name;
eDebug.innerHTML += "7. x:"+x+"<br />";
```

Variable `y` receives an object with properties `age` and `name`. Property `name` receives the string, Roy. Copy the `name` value to variable `x`. Display `x`. The output equals Roy.

### Question Eight

Source code for the eighth question follows. The answer equals `21`.

```y = {
age:20,
name:"Roy",
f:function(){
this.age++;
}
};
y.f();
x = y.age;
eDebug.innerHTML += "8. x:"+x+"<br />";
```

Variable `y` receives an object with properties `age, name` and `f`. Property `f` is a function which increments the value of property `age`.

Call function `f` as follows. After the first function call, property `age` now equals `21`.

```y.f();
```

Assign property `age` to `x` as follows.

```x = y.age;
```

Display `x`. The output equals `21`.

### Question Nine

Source code for the ninth question follows. The answer equals `object`.

```x = 0;
y = [1,2,3];
x = typeof y;
eDebug.innerHTML += "9. x:"+x+"<br />";
```

JavaScript (ES5), has three primitive types, String, Number and Boolean. Complex types include object and function. All other types, except `undefined`, are considered objects. Therefore arrays are objects.

Assign the array, `[1,2,3]`, to the variable `y`. The `typeof` operator returns `object` when the operand is an array.

### Question Ten

Source code for the tenth question follows. The answer equals `string`.

```y = "Chuck";
x = typeof y;
eDebug.innerHTML += "10. x:"+x+"<br />";
```

JavaScript (ES5), has three primitive types, String, Number and Boolean. Chuck is a string primitive type. The result equals `string`.

### Play Coding Maze Games

Play all six levels of coding mazes. Each level includes at least two different scenes.