fixed the logic error in the python verison for problem 2
fixed error logic of problem 2 in js version