Scientific Method Function In Javascript