check typeof in a function

We already know the typeof [] is Object. But we want it should be return Array. For that we will create a function.

function Solution(n){
  if(Array.isArray(n)){
    return 'Array';
  } else {
    return typeof n;
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *