Added JavaScript solution for type-checking problem