Build a table using JavaScript to merge cells with same values