JSFiddle - React, Tailwind, and code Playground

by bittersweetryan

JavaScript

function doSomething(any){

    if(typeof any === 'number'){
        alert("The number x2 is: " + any *2); 
    }
    else if(typeof any === 'string'){
        alert(any + " bar");    
    }
    else if(Object.prototype.toString.call( any ) === '[object Array]' ) {
        alert( "The array is " + any.length + " items long");
    }
        
}
    
    
doSomething(12);
doSomething("foo");
doSomething([1,2,3,4,5]);