title: converting between types in javascript
body: <p>I need to write a function that returns the last element from the input arguments. This is easy for Strings and Arrays, but the function can also accept a "list of arguments". I have tried to process this list of arguments with String and Array syntax, but I get errors about object not having method x. This is what I have so far:</p>
  
  <pre><code>function last(list){
    // return last element of array
    if(list instanceof Array){
      return list[list.length-1];
    }
    // return last element of string
    else if(typeof list === 'string'){
      return list.substring(list.length-1, list.length);
    }
  }
  </code></pre>
  
  <p>Is there a way to convert an arbitrary list of arguments to a String or Array? Here is an example of what I mean by list of arguments.</p>
  
  <pre><code>Test.assertEquals(last(1,"b",3,"d",5), 5);
  </code></pre>