Well-timed investments in technology and loyalty programs, combined with massive scale, allowed ​the U.S. retail giant to ...