javascript version of program