This is the basic pattern in data visulizatioon

svg.selectAll("rect")
    .data(dataset)
    .enter()

another trick is:

h = 400-d*5

because data's height is d*5, and svg's height is 400
so let h = 400 - d*5 will give the exact space for every
data, so it will represent the data very well
enter update and exit

after enter(), the join data will become the whole dataset
scale

scale.linear()
        about the method to scale, y = ax+b

scale.domain()

        about the orignal data

scale.range()
        about the scaled value