Defining String() class from scratch
<p>I got this exercise from a book (without solution): </p>

<blockquote>
  <p>Imagine the String() constructor didn't exist. Create a constructor function
  MyString() that acts like String() as closely as possible. You're not
  allowed to use any built-in string methods or properties, and remember that
  String() doesn't exist. You can use this code to test your constructor:</p>

<pre><code>&gt;&gt;&gt; var s = new MyString('hello');
&gt;&gt;&gt; s.length;
</code></pre>
</blockquote>

<p>Yet, I have a solution but not sure I followed the requirement (that is: "I am not allowed to use any built-in string methods or properties");
And here's my solution: </p>

<pre><code>function MyString(string) {
    this.length = 0;
    for(var i in string) { 
        this.length++;      
    }
}
var x = new MyString("Hello");
x.length;
</code></pre>

<p>The one that I am not sure about is the for-in loop. could you tell me what is the data type of <strong>string</strong> variable in that loop? Is that kind of array or Am I using it as String (that is I did break the requirement)?
Thanks a lot!</p>
