Jump to content


  • Posts

  • Joined

  • Last visited

sixwi's Achievements


Newbie (1/7)



  1. NEVERMIND - I figured it out.... but I can't figure out how to delete this topic! I'll go ahead and explain the function anyway. <script> var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo").innerHTML = isArray(fruits); function isArray(myArray) { return myArray.constructor.toString().indexOf("Array") > -1; } </script> Breakdown: The parameter (myArray) will be the "fruits" array. myArray.constructor would return "function Array() { [native code] }". Which gets converted to a string with the toString() method. Then the indexOf("Array") would be 9. (would be -1 if the word "Array" wasn't found) It then compares the result and since 9 > -1 the return is "true". If I can't get this deleted then I hope it helps someone. Thanks again
  2. Hello - first time posting. I've searched the forums to see if anyone else had the same question, with no luck. I'm going through the lessons in the tutorial but I can't figure out what's going on in part of the JS Type Conversion lesson. I'll link to the full lesson here, but below is the part I'm having trouble with: (mainly the function) I have no idea what's happening in the function... could someone be kind enough to break it down in detail for me? I understand how arrays work. But the function here has me stumped. Thanks so much
  • Create New...