Algorithms in Golang and Javascript