translate c to javascript