function drawBarChart (inputArray, chartTitle) {
const barChart = d3.create("svg");
barChart.attr("width", svgWidth);
barChart.attr("height", svgHeight);
barChart.append("g")
.attr('transform', `translate(${margin.left}, ${height + margin.top})`)
.call(d3.axisBottom(xScale));
barChart.append("g")
.attr('transform', `translate(${margin.left}, ${margin.top})`)
.call(d3.axisLeft(yScale));
barChart.append("text")
.attr("x", svgWidth / 2)
.attr("y", 20)
.attr("text-anchor", "middle")
.text(chartTitle);
barChart.append("text")
.attr("x", (width / 2)+margin.left)
.attr("y", svgHeight - 5)
.attr("text-anchor", "middle")
.attr("font-size", "14px")
.text("Year");
barChart.append("text")
.attr("x", -(margin.top + height / 2))
.attr("y", 15)
.attr("transform", "rotate(-90)")
.attr("text-anchor", "middle")
.attr("font-size", "14px")
.text("Population");
const barGroup = barChart.append("g")
.attr("class", "barGroup")
.attr("transform", `translate(${margin.left}, ${margin.top})`);
barGroup.selectAll("rect")
.data(inputArray)
.join("rect")
.attr("x", d => xScale(d.year))
.attr("y", d => yScale(d.pop))
.attr("width", xScale.bandwidth())
.attr("height", d => height - yScale(d.pop))
.attr("fill","steelblue");
return barChart.node();
}