How Does Reduce Function Work In Javascript