Basic javascript implementation of K-mean clustering